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;
|
day = (day < 10 ? "0" : "") + day;
|
||||||
return year + "-" + month + "-" + day + "_" + hour + "-" + min;
|
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) => {
|
var putlog = (msg) => {
|
||||||
fs.appendFileSync(log, msg, 'utf8');
|
fs.appendFileSync(log_forever, msg, 'utf8');
|
||||||
};
|
};
|
||||||
|
|
||||||
var child = new (forever.Monitor)('./src/main.js', {
|
var child = new (forever.Monitor)('./src/main.js', {
|
||||||
max: 3,
|
max: 1,
|
||||||
silent: false,
|
silent: true,
|
||||||
args: []
|
args: [],
|
||||||
|
|
||||||
|
watch: true,
|
||||||
|
watchIgnoreDotFiles: true,
|
||||||
|
watchIgnorePatterns: [
|
||||||
|
'*.log'
|
||||||
|
],
|
||||||
|
watchDirectory: __dirname,
|
||||||
|
logFile: log_bot,
|
||||||
|
outFile: log_bot,
|
||||||
|
errFile: log_bot
|
||||||
});
|
});
|
||||||
|
|
||||||
child.on('watch:restart', (info) => {
|
child.on('watch:restart', (info) => {
|
||||||
putlog('Restaring bot because ' + info.file + ' changed\n');
|
putlog('Restaring bot because ' + info.stat + ' changed\n');
|
||||||
});
|
});
|
||||||
child.on('restart', () => {
|
child.on('restart', () => {
|
||||||
putlog('restarting bot for ' + child.times + ' time\n');
|
putlog('restarting bot for ' + child.times + ' time\n');
|
||||||
|
@ -37,11 +48,7 @@ child.on('start', () => {
|
||||||
child.on('exit:code', (code) => {
|
child.on('exit:code', (code) => {
|
||||||
putlog('detected bot exited with code ' + code + '\n');
|
putlog('detected bot exited with code ' + code + '\n');
|
||||||
});
|
});
|
||||||
child.on('stdout', (data) => {
|
|
||||||
putlog(data);
|
|
||||||
});
|
|
||||||
child.on('stderr', (data) => {
|
child.on('stderr', (data) => {
|
||||||
putlog(data);
|
putlog(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
child.start();
|
child.start();
|
|
@ -23,4 +23,4 @@
|
||||||
},
|
},
|
||||||
"author": "Flummi & jkhsjdhjs",
|
"author": "Flummi & jkhsjdhjs",
|
||||||
"license": "WTFPL"
|
"license": "WTFPL"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user