Permalink
Browse files

add stop service option

  • Loading branch information...
jfromaniello committed Jun 1, 2012
1 parent 3e0e02f commit a34e5617d160fe6e11e2eb85ca31dee766f59c60
Showing with 16 additions and 8 deletions.
  1. +16 −8 bin/winser
View
@@ -19,6 +19,7 @@ program
.version(require("../package.json").version)
.option("-i, --install", "install the node application as a windows service")
.option("-r, --remove", "remove the windows service for the node application")
+ .option("-x, --stop", "stop the service. Useful in conjuntion with -r")
.option("-s, --silent", "supress any information in the console")
.option("-c, --confirmation", "ask for confirmation before installing")
.option("-p, --path [path]", "path to the node application you want to install as a service [current directory]", process.cwd())
@@ -61,26 +62,33 @@ sequence
});
})
.then(function(next){
- exec("where npm.cmd", function(err, r){
- var npmPath = r.trim().split("\r\n")[0];
- next(err, npmPath);
- });
- })
- .then(function(next, err, npmLocation){
if (!program.confirmation) {
- next(err, npmLocation);
+ next();
}else{
var message = program.install ? "continue installing " + appName + " as a service? " :
"continue uninstalling the " + appName + " service? ";
program.confirm(message, function(ok){
if(ok){
- next(err, npmLocation);
+ next();
}else{
process.exit();
}
});
}
})
+ .then(function(next){
+ if(!program.stop){
+ next();
+ return;
+ }
+ exec("net stop " + appName, next);
+ })
+ .then(function(next){
+ exec("where npm.cmd", function(err, r){
+ var npmPath = r.trim().split("\r\n")[0];
+ next(err, npmPath);
+ });
+ })
.then(function(next, err, npmLocation){
if(program.install){
exec('{binfolder}\\nssm.exe install {serviceName} "{npmLocation}" start "{appFolder}"'.supplant({

0 comments on commit a34e561

Please sign in to comment.