From 529a640d9e13a3284da7136e8168486b5ec3b27d Mon Sep 17 00:00:00 2001 From: Matthew R Date: Tue, 7 Jul 2020 21:16:56 -0400 Subject: [PATCH] changes to go func --- src/intervals/storage.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/intervals/storage.ts b/src/intervals/storage.ts index a3298a0..a2499ac 100644 --- a/src/intervals/storage.ts +++ b/src/intervals/storage.ts @@ -11,6 +11,17 @@ export default async function storage(client: Client) { return (accounts * 2) * 60000; } let intervalTiming = await determineInterval(client); + + async function start() { + const storageDaemon = spawn(`${__dirname}/../bin/storage`, [], { cwd: __dirname }); + storageDaemon.stdout.on('data', (data) => client.signale.log(data.toString())); + storageDaemon.stderr.on('data', (data) => client.signale.log(data.toString())); + storageDaemon.on('exit', (code) => { + client.signale.log(`CSD-GO-STR Daemon exited with code ${code}.`); + storageDaemon.removeAllListeners(); + client.signale.info(`Reactivating CSD-GO-STR daemon startup interval. Reactivating in ${intervalTiming / 60000}min.`); + }); + } /* let storageGo = spawn(`${__dirname}/../bin/storage`, [], { cwd: __dirname }); storageGo.stdout.on('data', (data) => client.signale.log(data.toString())); storageGo.stderr.on('data', (data) => client.signale.log(data.toString())); @@ -21,14 +32,7 @@ export default async function storage(client: Client) { client.signale.info(`Activated CSD-GO-STR daemon startup interval. Starting in ${intervalTiming / 60000}min.`); interval = setInterval(async () => { intervalTiming = await determineInterval(client); - const storageDaemon = spawn(`${__dirname}/../bin/storage`, [], { cwd: __dirname }); - storageDaemon.stdout.on('data', (data) => client.signale.log(data.toString())); - storageDaemon.stderr.on('data', (data) => client.signale.log(data.toString())); - storageDaemon.on('exit', (code) => { - client.signale.log(`CSD-GO-STR Daemon exited with code ${code}.`); - storageDaemon.removeAllListeners(); - client.signale.info(`Reactivating CSD-GO-STR daemon startup interval. Reactivating in ${intervalTiming / 60000}min.`); - }); + await start(); }, intervalTiming); }