From ace7594c124a3b8e696679d441820fab4b4de053 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Fri, 20 Dec 2019 12:18:19 -0500 Subject: [PATCH] should be spawn instead of execFile --- src/intervals/storage.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/intervals/storage.ts b/src/intervals/storage.ts index 2c9cdd7..d93da4e 100644 --- a/src/intervals/storage.ts +++ b/src/intervals/storage.ts @@ -1,5 +1,6 @@ /* eslint-disable no-await-in-loop */ // import fs from 'fs-extra'; +import { spawn } from 'child_process'; import { Client } from '..'; export default async function storage(client: Client) { @@ -24,5 +25,11 @@ export default async function storage(client: Client) { setInterval(async () => { await main(); }, 900000); */ - (await import('child_process')).execFile('./storage'); + let storageGo = spawn('./storage', []); + storageGo.stdout.on('data', (data) => client.signale.log(data)); + storageGo.stderr.on('data', (data) => client.signale.log(data)); + storageGo.on('exit', (code) => { + client.signale.log(`Go storage func exited with code ${code}, restarting`); + storageGo = spawn('./storage', []); + }); }