fixed forever

This commit is contained in:
Flummi 2016-08-31 20:21:12 +00:00
parent 205ede37a2
commit 8ef12776c0
2 changed files with 18 additions and 11 deletions

27
bot.js
View File

@ -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();

View File

@ -23,4 +23,4 @@
},
"author": "Flummi & jkhsjdhjs",
"license": "WTFPL"
}
}