I'm retard
All checks were successful
Docker build image / build (push) Successful in 26s

This commit is contained in:
Fijxu 2024-10-12 02:32:56 -03:00
parent 8738a17b29
commit 84770fb410
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4

View file

@ -2,7 +2,6 @@ const { createTask } = require('./lib/task')
const { fetchVisitorData } = require('./lib/workflow') const { fetchVisitorData } = require('./lib/workflow')
const { Redis } = require('ioredis') const { Redis } = require('ioredis')
const redis = new Redis({ host: process.env.HOST || config.host }); const redis = new Redis({ host: process.env.HOST || config.host });
redis.on('error', (error) => { redis.on('error', (error) => {
@ -11,24 +10,29 @@ redis.on('error', (error) => {
}); });
const generate = async () => { const generate = async () => {
console.debug("[DEBUG] generate called")
try {
const visitorData = await fetchVisitorData() const visitorData = await fetchVisitorData()
const task = await createTask(visitorData) const task = await createTask(visitorData)
const { poToken } = await task.start() const { poToken } = await task.start()
return { visitorData, poToken } return { visitorData, poToken }
} catch (e) {
console.error(`generate: Error ${e}`)
}
} }
const run = async () => { const run = async () => {
try { try {
const { visitorData, poToken } = await generate(); const { visitorData, poToken } = await generate();
p = redis.set("invidious:po_token", poToken) redis.set("invidious:po_token", poToken)
v = redis.set("invidious:visitor_data", visitorData) redis.set("invidious:visitor_data", visitorData)
} catch(e) { } catch(e) {
console.error(`Fuck: ${e}`) console.error(`run: Error ${e}`)
} }
console.log("New tokens sent to redis") console.log("New tokens sent to redis")
} }
run(); run();
setTimeout(run, (process.env.RENEW_INTERVAL || 60) * 1000) setInterval(run, (process.env.RENEW_INTERVAL || 60) * 1000)
module.exports = { generate } module.exports = { generate }