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 +}