Skip to content

Commit

Permalink
call tartarus.load again if db loading fails
Browse files Browse the repository at this point in the history
  • Loading branch information
alseambusher committed Jan 2, 2017
1 parent 58d6816 commit 81f6e12
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/background.js
Original file line number Diff line number Diff line change
@@ -26,7 +26,8 @@ if (env.name !== 'production') {
}

app.on('ready', function () {
exec(path.join(__dirname, '/node_modules/pm2/bin/pm2') + ' start ' + path.join(__dirname, '/tartarus-process.js'), function (error, stdout, stderr) {
// TODO remove node and find an alternative to pm2 to make the binaries independent of node
exec('node '+ path.join(__dirname, '/node_modules/pm2/bin/pm2') + ' start ' + path.join(__dirname, '/tartarus-process.js'), function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
15 changes: 12 additions & 3 deletions src/lib/tartarus.js
Original file line number Diff line number Diff line change
@@ -18,13 +18,22 @@ export var files, schedules, settings;

export function load() {
settingsDb.loadDatabase(function (err) {
if (err) throw err;
if (err) {
setTimeout(load, 100);
return;
}
});
filesDb.loadDatabase(function (err) {
if (err) throw err;
if (err) {
setTimeout(load, 100);
return;
}
});
schedulesDb.loadDatabase(function (err) {
if (err) throw err;
if (err) {
setTimeout(load, 100);
return;
}
});
settings = new Settings(settingsDb);
schedules = new Schedules(schedulesDb);

0 comments on commit 81f6e12

Please sign in to comment.