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 93bed6113b5761638840d394a9485f22b803ef5c
parent 9e45758922f5671f6a1062bb93800789cbc14689
Author: Marcel Radzio <marcel@radzio-sh.de>
Date:   Sun, 13 Dec 2015 02:19:54 +0100

Add fix that it is not restarting always at 2 o'clock - git pull not working

Diffstat:
Mmain.js | 31+++++++++++++++++++++++++------
Atmp/gitkeep | 0
Atmp/restart | 0
3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/main.js b/main.js @@ -2,6 +2,7 @@ var request = require('request'); var git = require('simple-git'); var schedule = require('node-schedule'); var argv = require('yargs').argv; +var fs = require('fs'); //LOAD MODULES DOWN HERE var pushbullet = require('./handlers/pushbullet.js'); var irc = require('./handlers/irc.js'); @@ -71,19 +72,37 @@ irc.ircBotCommands(); if (!argv.noupdate) { var j = schedule.scheduleJob('* 2 * * *', function(){ console.log('Start Update!'); - bot.ircEndCustom('Start update! Coming back in a few Seconds!'); - git.pull(function(err, update) { - if(update && update.summary.changes) { + 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") { 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!"); + }); }); } if (argv.noupdate) { - var j = schedule.scheduleJob('* 2 * * *', function(){ + var k = schedule.scheduleJob('* 2 * * *', function(){ console.log('Daily restart!'); - bot.ircEndCustom('Daily restart! Coming back in a few Seconds!'); - require('child_process').exec('npm restart'); + irc.ircEndCustom('Daily restart! Coming back in a few Seconds!'); + if (fs.readFile("tmp/restart") !== "1") { + require('child_process').exec('npm restart'); + } }); } +var l = schedule.scheduleJob('* 3 * * *', function(){ + fs.writeFile("tmp/restart", "0", function(err) { + if(err) { + return console.log(err); + } + + console.log("The file was saved!"); + }); +}); setTimeout(function() { MakePush(); }, 20000); diff --git a/tmp/gitkeep b/tmp/gitkeep diff --git a/tmp/restart b/tmp/restart