freifunk-bot

Modular parser for the hackerspace door status with handlers for multiple services
git clone git://archive.git.mtrnord.blog/MTRNord/freifunk-bot.git
Log | Files | Refs | README | LICENSE

commit b3ea771fdd22c1bb6ef4228d495e4408597d79a2
parent 93bed6113b5761638840d394a9485f22b803ef5c
Author: Marcel Radzio <marcel@radzio-sh.de>
Date:   Sun, 13 Dec 2015 02:33:46 +0100

Fix restart loop - git.pull() still not working

Diffstat:
Mmain.js | 15++++++++++++---
Mtmp/restart | 2++
2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/main.js b/main.js @@ -74,7 +74,8 @@ if (!argv.noupdate) { console.log('Start Update!'); irc.ircEndCustom('Start update! Coming back in a few Seconds!'); git.pull("origin", "master", function(err, update) { - if(update && update.summary.changes && fs.readFile("tmp/restart") !== "1") { + var restartFile = fs.readFileSync("tmp/restart", "utf8"); + if(update && update.summary.changes && restartFile !== "1") { require('child_process').exec('npm restart'); } }); @@ -91,9 +92,17 @@ if (argv.noupdate) { var k = schedule.scheduleJob('* 2 * * *', function(){ console.log('Daily restart!'); irc.ircEndCustom('Daily restart! Coming back in a few Seconds!'); - if (fs.readFile("tmp/restart") !== "1") { + var restartFile = fs.readFileSync("tmp/restart", "utf8"); + console.log(restartFile); + if (restartFile !== "1") { require('child_process').exec('npm restart'); } + fs.writeFile("tmp/restart", "1", function(err) { + if(err) { + return console.log(err); + } + console.log("The file was saved!"); + }); }); } var l = schedule.scheduleJob('* 3 * * *', function(){ @@ -103,6 +112,6 @@ var l = schedule.scheduleJob('* 3 * * *', function(){ } console.log("The file was saved!"); - }); + }); }); setTimeout(function() { MakePush(); }, 20000); diff --git a/tmp/restart b/tmp/restart @@ -0,0 +1 @@ +1 +\ No newline at end of file