1
0
mirror of synced 2024-11-16 11:03:50 +00:00

Cleaned up initial config loading

Added WorkingDirectory to service unit in readme
This commit is contained in:
Mark van Renswoude 2016-08-07 13:26:20 +02:00
parent 62302ffaa1
commit 0cdeee314d
2 changed files with 9 additions and 20 deletions

View File

@ -30,6 +30,7 @@ Description=SecurityCam server
[Service]
ExecStart=/usr/local/bin/node /srv/securitycam/index.js
WorkingDirectory=/srv/securitycam
Restart=always
RestartSec=10 # Restart service after 10 seconds if node service crashes
StandardOutput=syslog # Output to syslog

View File

@ -225,27 +225,15 @@ app.get('/capture/:camId', function(req, res)
}
});
var watcher = chokidar.watch('./config.js');
var firstLoad = true;
loadConfig();
var watcher = chokidar.watch('./config.js',
{
ignoreInitial: true
});
watcher.on('all', function()
{
if (!firstLoad)
logger.verbose('Configuration change detected, reloading...');
logger.verbose('Configuration change detected, reloading...');
loadConfig();
firstLoad = false;
});
// It looks like the add event from chokidar will always be fired immediately,
// at least on Windows, but I couldn't find anything in the documentation so
// let's not make that assumption and double-check.
setTimeout(function()
{
if (firstLoad)
{
loadConfig();
firstLoad = false;
}
}, 1000);
});