From 8ef12776c0ea9d921eba01f68b8f00628773c7a4 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 31 Aug 2016 20:21:12 +0000 Subject: [PATCH] fixed forever --- bot.js | 27 +++++++++++++++++---------- package.json | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/bot.js b/bot.js index 953aa8f..4a3ef85 100644 --- a/bot.js +++ b/bot.js @@ -14,19 +14,30 @@ var getDateTimeString = () => { day = (day < 10 ? "0" : "") + day; return year + "-" + month + "-" + day + "_" + hour + "-" + min; }; -var log = './log/bot_'+getDateTimeString()+'.log'; +var log_forever = './log/forever_'+getDateTimeString()+'.log'; +var log_bot = './log/bot_'+getDateTimeString()+'.log'; var putlog = (msg) => { - fs.appendFileSync(log, msg, 'utf8'); + fs.appendFileSync(log_forever, msg, 'utf8'); }; var child = new (forever.Monitor)('./src/main.js', { - max: 3, - silent: false, - args: [] + max: 1, + silent: true, + args: [], + + watch: true, + watchIgnoreDotFiles: true, + watchIgnorePatterns: [ + '*.log' + ], + watchDirectory: __dirname, + logFile: log_bot, + outFile: log_bot, + errFile: log_bot }); child.on('watch:restart', (info) => { - putlog('Restaring bot because ' + info.file + ' changed\n'); + putlog('Restaring bot because ' + info.stat + ' changed\n'); }); child.on('restart', () => { putlog('restarting bot for ' + child.times + ' time\n'); @@ -37,11 +48,7 @@ child.on('start', () => { child.on('exit:code', (code) => { putlog('detected bot exited with code ' + code + '\n'); }); -child.on('stdout', (data) => { - putlog(data); -}); child.on('stderr', (data) => { putlog(data); }); - child.start(); \ No newline at end of file diff --git a/package.json b/package.json index bbfcc25..c80a6a6 100644 --- a/package.json +++ b/package.json @@ -23,4 +23,4 @@ }, "author": "Flummi & jkhsjdhjs", "license": "WTFPL" -} \ No newline at end of file +}