From 0ec275af690d472389eaaa69c47acf4ea4d8ceff Mon Sep 17 00:00:00 2001 From: Unitech Date: Tue, 6 Dec 2016 16:31:01 +0100 Subject: [PATCH] (startup) launchd auto restart + unstartup launchd --- lib/API/Startup.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/API/Startup.js b/lib/API/Startup.js index bb772238..ce70a9c4 100644 --- a/lib/API/Startup.js +++ b/lib/API/Startup.js @@ -97,16 +97,24 @@ module.exports = function(CLI) { 'rm /etc/init.d/pm2' ]; break; + case 'launchd': + var destination = path.join(process.env.HOME, 'Library/LaunchAgents/PM2.plist'); + commands = [ + 'launchctl remove com.PM2', + 'rm ' + destination + ]; }; - shelljs.exec(commands.join('; '), function(err, stdout, stderr) { + shelljs.exec(commands.join('; '), function(code, stdout, stderr) { console.log(stdout); console.log(stderr); - if (err) { - Common.printError(err); - return cb(Common.retErr(err)); + if (code == 0) { + Common.printOut(cst.PREFIX_MSG + chalk.bold('Init file disabled.')); } - cb(); + cb(null, { + commands : commands, + platform : platform + }); }); };