mirror of
https://github.com/iv-org/invidious.git
synced 2025-07-18 03:18:30 +00:00
tokenmon cleanup
This commit is contained in:
parent
4bdbdfdc12
commit
588247ddfa
40
src/invidious/helpers/tokenmon.cr
Normal file
40
src/invidious/helpers/tokenmon.cr
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
class Invidious::TokenMon
|
||||||
|
|
||||||
|
@@instance = new
|
||||||
|
|
||||||
|
def self.pot
|
||||||
|
@@pot
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.vdata
|
||||||
|
@@vdata
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
|
||||||
|
@@pot = "error"
|
||||||
|
@@vdata = "error"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.get_tokens
|
||||||
|
|
||||||
|
# Load config from file or YAML string env var
|
||||||
|
env_config_file = "INVIDIOUS_CONFIG_FILE"
|
||||||
|
env_config_yaml = "INVIDIOUS_CONFIG"
|
||||||
|
|
||||||
|
config_file = ENV.has_key?(env_config_file) ? ENV.fetch(env_config_file) : "config/config.yml"
|
||||||
|
config_yaml = ENV.has_key?(env_config_yaml) ? ENV.fetch(env_config_yaml) : File.read(config_file)
|
||||||
|
|
||||||
|
config = Config.from_yaml(config_yaml)
|
||||||
|
|
||||||
|
@@pot = config.po_token
|
||||||
|
@@vdata = config.visitor_data
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.get_instance
|
||||||
|
return @@instance
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
17
src/invidious/jobs/tokenmon.cr
Normal file
17
src/invidious/jobs/tokenmon.cr
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
class Invidious::Jobs::MonitorCfgTokensJob < Invidious::Jobs::BaseJob
|
||||||
|
include Invidious
|
||||||
|
def begin
|
||||||
|
loop do
|
||||||
|
|
||||||
|
LOGGER.info("jobs: running MonitorCfgTokensJob job")
|
||||||
|
|
||||||
|
Invidious::TokenMon.get_tokens
|
||||||
|
|
||||||
|
LOGGER.info("jobs: MonitorCfgTokensJob: pot: " + Invidious::TokenMon.pot.as(String))
|
||||||
|
LOGGER.info("jobs: MonitorCfgTokensJob: vdata: " + Invidious::TokenMon.vdata.as(String))
|
||||||
|
|
||||||
|
sleep 1.minutes
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user