fixed forever
This commit is contained in:
parent
205ede37a2
commit
8ef12776c0
27
bot.js
27
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();
|
Loading…
Reference in New Issue
Block a user