diff --git a/src/backend/index.ts b/src/backend/index.ts index 0f1e657c..aca0d5d9 100644 --- a/src/backend/index.ts +++ b/src/backend/index.ts @@ -25,6 +25,7 @@ import { getDb, performDbMigrationWithBackup } from './common/database/drizzle/d import { getDbPath } from './common/database/Database.js'; import { createRetentionCleanupTask } from './tasks/retentionCleanup.js'; import { parseUserConfig } from './common/Cache.js'; +import { nonEmptyStringOrDefault } from '../core/StringUtils.js'; dayjs.extend(utc) dayjs.extend(isBetween); @@ -156,9 +157,8 @@ const configDir = process.env.CONFIG_DIR || path.resolve(projectDir, `./config`) if(nameColl.length > 0) { logger.warn(`Last.FM source and clients have same names [${nameColl.map(x => x.name).join(',')}] -- this may cause issues`); } - - for(const c of scrobbleClients.clients) { - c.initTasks(); + const clientInitOptions = {deadDelay: nonEmptyStringOrDefault(process.env.DEBUG_DEAD_DELAY, undefined) !== undefined ? Number.parseInt(process.env.DEBUG_DEAD_DELAY) : undefined}; for(const c of scrobbleClients.clients) { + c.initTasks(clientInitOptions); const res = await Promise.race([ sleep(2200), (async () => { diff --git a/src/backend/scrobblers/AbstractScrobbleClient.ts b/src/backend/scrobblers/AbstractScrobbleClient.ts index bbd2b0d2..1f886525 100644 --- a/src/backend/scrobblers/AbstractScrobbleClient.ts +++ b/src/backend/scrobblers/AbstractScrobbleClient.ts @@ -259,7 +259,8 @@ export default abstract class AbstractScrobbleClient extends AbstractComponent i this.initializeNowPlayingSchedule(); if(this.scheduler.existsById('dead') === false && this.initDeadTimeout === undefined) { - this.logger.verbose('Delaying Dead Scrobbler Processing Task by 2 minutes'); + const deadDelay = opts.deadDelay ?? 120; + this.logger.verbose(`Delaying Dead Scrobbler Processing Task by ${deadDelay} seconds`); this.initDeadTimeout = setTimeout(() => { this.logger.info('Adding Dead Scrobbler Processing Task and running immediately'); this.initDeadTimeout = undefined; @@ -280,8 +281,7 @@ export default abstract class AbstractScrobbleClient extends AbstractComponent i this.logger.error(err); } ), {id: 'dead'})); - // delay for 2 minutes - }, (opts.deadDelay ?? 120) * 1000); + }, deadDelay * 1000); } else { if(this.initDeadTimeout !== undefined) {