2

The script i want to run as a service requires 'start' as parameter.

How do i setup the parameter with node-windows?

Here the setup js script from the project page:

var Service = require('node-windows').Service;

// Create a new service object
var svc = new Service({
  name:'Hello World',
  description: 'The nodejs.org example web server.',
  script: 'C:\\path\\to\\wiki.js',
  nodeOptions: [
    '--harmony',
    '--max_old_space_size=4096'
  ]
});

// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
  svc.start();
});

svc.install();

Setting script value as 'wiki start' result in error because the module treats it as a file. Here the log:

Starting C:\Program Files\nodejs\node.exe  --harmony --max_old_space_size=4096 C:\Users\<me>\AppData\Roaming\npm\node_modules\node-windows\lib\wrapper.js --file ..\wiki.js --log "wiki.js wrapper" --grow 0.25 --wait 1 --maxrestarts 3 --abortonerror n --stopparentfirst undefined "-- start"

I also try to send in nodeOptions, adding '-- start' to array but the module add it to the command line as string, i.e. "-- start".

MiguelSlv
  • 14,067
  • 15
  • 102
  • 169

1 Answers1

0

This is what the scriptOptions parameter is for. It was introduced with node-windows@0.1.11

var svc = new Service({
  name:'Hello World',
  description: 'The nodejs.org example web server.',
  script: 'C:\\path\\to\\wiki.js',
  scriptOptions: 'start'
});
mojoaxel
  • 1,440
  • 1
  • 14
  • 19