-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix : exec update script in detached process
- Loading branch information
1 parent
f703c12
commit 11dec2e
Showing
1 changed file
with
10 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |