Skip to content

Commit

Permalink
bugfix : exec update script in detached process
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles committed Sep 18, 2016
1 parent f703c12 commit 11dec2e
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions api/core/system/system.update.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
var child_process = require('child_process');
const spawn = require('child_process').spawn;

module.exports = function(){
return exec(sails.config.update.updateScript);
}
const child = spawn('sh', [sails.config.update.updateScript], {
detached: true,
stdio: 'ignore'
});

/**
* Exec a shell command
*/
function exec(command){
return new Promise(function(resolve, reject){
child_process.exec(command, function (err, stdout, stderr){
if(err) return reject(err);

return resolve(stdout);
});
child.on('error', (err) => {
sails.log.error('Failed to start update script');
sails.log.error(err);
});

child.unref();
}

0 comments on commit 11dec2e

Please sign in to comment.