Socket
Socket
Sign inDemoInstall

node-windows

Package Overview
Dependencies
2
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-beta.6 to 1.0.0-beta.7

0

bin/sudowin/LICENSE.txt

@@ -0,0 +0,0 @@ Copyright (c) 2005-2008, Schley Andrew Kutz <akutz@lostcreations.com>

@@ -0,0 +0,0 @@ var path = require('path'),

4

lib/cmd.js

@@ -43,3 +43,3 @@ var exec = require('child_process').exec,

if (typeof isNaN(pid)) {
if (isNaN(pid)) {
throw new Error('PID must be a number.')

@@ -90,2 +90,2 @@ }

};
};

@@ -158,3 +158,3 @@ /**

},
/**

@@ -168,5 +168,5 @@ * @cfg {Boolean} [stopparentfirst=false]

configurable: false,
value: config.stopparentfirst
value: config.hasOwnProperty('stopparentfirst') ? config.stopparentfirst : false
},
/**

@@ -183,5 +183,5 @@ * @cfg {Number} [stoptimeout=30]

},
/**
* @cfg {string} [nodeOptions='--harmony']
* @cfg {string} [nodeOptions]
* Options to be passed to the node process.

@@ -193,5 +193,5 @@ */

configurable: false,
value: config.nodeOptions || '--harmony'
value: config.nodeOptions
},
/**

@@ -207,3 +207,3 @@ * @cfg {string} [scriptOptions='']

},
/**

@@ -210,0 +210,0 @@ * @cfg {Number} [maxRestarts=3]

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ module.exports = {

// Handle input parameters
var Logger = require('./eventlog'),
optimist = require('optimist'),
Args = require('@author.io/args'),
net = require('net'),
max = 60,
p = require('path'),
argv = optimist
.demand('file')
.alias('f','file')
.describe('file','The absolute path of the script to be run as a process.')
.check(function(argv){
require('fs').existsSync(p.resolve(argv.f),function(exists){
return exists;
});
})
.describe('scriptoptions','The options to be sent to the script.')
.alias('d','cwd')
.describe('cwd','The absolute path of the current working directory of the script to be run as a process.')
// .check(function(argv){
// require('fs').existsSync(p.resolve(argv.d),function(exists){
// return exists;
// });
// })
.demand('log')
.alias('l','log')
.describe('log','The descriptive name of the log for the process')
.default('eventlog','APPLICATION')
.alias('e','eventlog')
.describe('eventlog','The event log container. This must be APPLICATION or SYSTEM.')
.default('maxretries',-1)
.alias('m','maxretries')
.describe('maxretries','The maximim number of times the process will be auto-restarted.')
.default('maxrestarts',5)
.alias('r','maxrestarts')
.describe('maxrestarts','The maximim number of times the process should be restarted within a '+max+' second period shutting down.')
.default('wait',1)
.alias('w','wait')
.describe('wait','The number of seconds between each restart attempt.')
.check(function(argv){
return argv.w >= 0;
})
.default('grow',.25)
.alias('g','grow')
.describe('grow','A percentage growth rate at which the wait time is increased.')
.check(function(argv){
return (argv.g >= 0 && argv.g <= 1);
})
.default('abortonerror','no')
.alias('a','abortonerror')
.describe('abortonerror','Do not attempt to restart the process if it fails with an error,')
.check(function(argv){
return ['y','n','yes','no'].indexOf(argv.a.trim().toLowerCase()) >= 0;
})
.default('stopparentfirst', 'no')
.alias('s', 'stopparentfirst')
.describe('stopparentfirst', 'Allow the script to exit using a shutdown message.')
.check(function(argv){
return ['y','n','yes','no'].indexOf(argv.a.trim().toLowerCase()) >= 0;
})
.argv,
log = new Logger(argv.e == undefined ? argv.l : {source:argv.l,eventlog:argv.e}),
fork = require('child_process').fork,
script = p.resolve(argv.f),
wait = argv.w*1000,
grow = argv.g+1,
attempts = 0,
startTime = null,
starts = 0,
child = null
child = null,
forcekill = false;
if (argv.d){
if (!require('fs').existsSync(p.resolve(argv.d))){
console.warn(argv.d+' not found.');
argv.d = process.cwd();
Args.configure({
file: {
type: 'string',
required: true,
alias: 'f',
description: 'The absolute path of the script to be run as a process.',
validate: function(value){
require('fs').existsSync(p.resolve(value),function(exists){
return exists;
});
}
},
scriptoptions: {
type: 'string',
description: 'The options to be sent to the script.'
},
cwd: {
type: 'string',
description: 'The absolute path of the current working directory of the script to be run as a process.',
alias: 'd',
validate: function(value){
require('fs').existsSync(p.resolve(value),function(exists){
return exists;
});
}
},
log: {
type: 'string',
required: true,
alias: 'l',
description: 'The descriptive name of the log for the process'
},
eventlog: {
type: 'string',
alias: 'e',
description: 'The event log container. This must be APPLICATION or SYSTEM.',
defaults: 'APPLICATION'
},
maxretries: {
type: 'number',
alias: 'm',
description: 'The maximim number of times the process will be auto-restarted.',
defaults: -1
},
maxrestarts: {
type: 'number',
alias: 'r',
description: 'The maximim number of times the process should be restarted within a '+max+' second period shutting down.',
defaults: 5
},
wait: {
type: 'number',
alias: 'w',
description: 'The number of seconds between each restart attempt.',
defaults: 1,
validate: function(value){
return value >= 0;
}
},
grow: {
type: 'number',
alias: 'g',
description: 'A percentage growth rate at which the wait time is increased.',
defaults: .25,
validate: function(value){
return value >= 0 && value <= 1;
}
},
abortonerror: {
type: 'string',
alias: 'a',
description: 'Do not attempt to restart the process if it fails with an error.',
defaults: 'no',
options: ['y','n','yes','no']
},
stopparentfirst: {
type: 'string',
alias: 's',
decribe: 'Allow the script to exit using a shutdown message.',
defaults: 'no',
options: ['y','n','yes','no']
}
});
Args.disallowUnrecognized();
Args.enforceRules();
var argv = Args.data,
log = new Logger(argv.eventlog == undefined ? argv.log : {source:argv.log,eventlog:argv.eventlog}),
script = p.resolve(argv.file),
wait = argv.wait*1000,
grow = argv.grow+1;
if (argv.cwd){
if (!require('fs').existsSync(p.resolve(argv.cwd))){
console.warn(argv.cwd+' not found.');
argv.cwd = process.cwd();
}
argv.d = p.resolve(argv.d);
argv.cwd = p.resolve(argv.cwd);
}
if (typeof argv.m === 'string'){
argv.m = parseInt(argv.m);
if (typeof argv.maxretries === 'string'){
argv.maxretries = parseInt(argv.maxretries);
}
// Set the absolute path of the file
argv.f = p.resolve(argv.f);
argv.file = p.resolve(argv.file);

@@ -103,3 +137,3 @@ // Hack to force the wrapper process to stay open by launching a ghost socket server

// If the number of periodic starts exceeds the max, kill the process
if (starts >= argv.r){
if (starts >= argv.maxrestarts){
if (new Date().getTime()-(max*1000) <= startTime.getTime()){

@@ -114,4 +148,4 @@ log.error('Too many restarts within the last '+max+' seconds. Please check the script.');

attempts += 1;
if (attempts > argv.m && argv.m >= 0){
log.error('Too many restarts. '+argv.f+' will not be restarted because the maximum number of total restarts has been exceeded.');
if (attempts > argv.maxretries && argv.maxretries >= 0){
log.error('Too many restarts. '+argv.file+' will not be restarted because the maximum number of total restarts has been exceeded.');
process.exit();

@@ -125,3 +159,3 @@ } else {

attempts = 0;
wait = argv.w * 1000;
wait = argv.wait * 1000;
}

@@ -144,3 +178,3 @@ };

//log.info('Starting '+argv.f);
//log.info('Starting '+argv.file);
if (logLevel && msg) {

@@ -163,4 +197,4 @@ log[logLevel](msg);

var args = [];
if (argv.d) opts.cwd = argv.d;
if (argv.s) opts.detached = true;
if (argv.cwd) opts.cwd = argv.cwd;
if (argv.stopparentfirst) opts.detached = true;
if (argv.scriptoptions) args = argv.scriptoptions.split(' ');

@@ -171,7 +205,7 @@ child = fork(script,args,opts);

child.on('exit',function(code){
log.warn(argv.f+' stopped running.');
log.warn(argv.file+' stopped running.');
// If an error is thrown and the process is configured to exit, then kill the parent.
if (code !== 0 && argv.a == "yes"){
log.error(argv.f+' exited with error code '+code);
if (code !== 0 && argv.abortonerror == "yes"){
log.error(argv.file+' exited with error code '+code);
process.exit();

@@ -192,3 +226,3 @@ //server.unref();

if (child) {
if (argv.s) {
if (argv.stopparentfirst) {
child.send('shutdown');

@@ -199,3 +233,3 @@ } else {

} else {
log.warn('Attempted to kill an unrecognized process.')
log.warn('Attempted to kill an unrecognized process.');
}

@@ -213,2 +247,2 @@ }

// Launch the process
launch('info', 'Starting ' + argv.f);
launch('info', 'Starting ' + argv.file);
{
"name": "node-windows",
"version": "1.0.0-beta.6",
"version": "1.0.0-beta.7",
"description": "Support for Windows services, event logging, UAC, and several helper methods for interacting with the OS.",

@@ -18,8 +18,7 @@ "keywords": [

"author": "Corey Butler <corey@coreybutler.com>",
"devDependencies": {},
"main": "lib/node-windows.js",
"preferGlobal": true,
"dependencies": {
"optimist": "~0.6.0",
"xml": "0.0.12"
"@author.io/arg": "1.3.22",
"xml": "1.0.1"
},

@@ -26,0 +25,0 @@ "readmeFilename": "README.md",

@@ -0,0 +0,0 @@ # node-windows

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc