Cleaned up initial config loading
Added WorkingDirectory to service unit in readme
This commit is contained in:
parent
62302ffaa1
commit
0cdeee314d
|
@ -30,6 +30,7 @@ Description=SecurityCam server
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/usr/local/bin/node /srv/securitycam/index.js
|
ExecStart=/usr/local/bin/node /srv/securitycam/index.js
|
||||||
|
WorkingDirectory=/srv/securitycam
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10 # Restart service after 10 seconds if node service crashes
|
RestartSec=10 # Restart service after 10 seconds if node service crashes
|
||||||
StandardOutput=syslog # Output to syslog
|
StandardOutput=syslog # Output to syslog
|
||||||
|
|
28
index.js
28
index.js
|
@ -225,27 +225,15 @@ app.get('/capture/:camId', function(req, res)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var watcher = chokidar.watch('./config.js');
|
loadConfig();
|
||||||
var firstLoad = true;
|
|
||||||
|
var watcher = chokidar.watch('./config.js',
|
||||||
|
{
|
||||||
|
ignoreInitial: true
|
||||||
|
});
|
||||||
|
|
||||||
watcher.on('all', function()
|
watcher.on('all', function()
|
||||||
{
|
{
|
||||||
if (!firstLoad)
|
logger.verbose('Configuration change detected, reloading...');
|
||||||
logger.verbose('Configuration change detected, reloading...');
|
|
||||||
|
|
||||||
loadConfig();
|
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);
|
|
Loading…
Reference in New Issue