There's already a thread on this subject (here), but it doesn't answer my situation (most of the answers make suggestions for alternatives to node-windows instead of addressing why the service it creates stops running).
Like the title says, I used the node-windows package to create a service (run my node app script). It runs locally but when I install it on a windows 2012 server, the service stops after a few seconds after starting.
Here are the errors found in Event Viewer:
- Starting D:\Program Files\nodejs\node.exe --harmony "D:\Program Files\otherApps\create-windows-service-for-nodejs\node_modules\node-windows\lib\wrapper.js" --file "D:\Program Files\path\to\my\application\index.js" --log "Node.js Service Management API wrapper" --grow 0.25 --wait 1 --maxrestarts 3 --abortonerror n --stopparentfirst undefined
- Service started successfully.
- Starting D:\Program Files\path\to\my\application\index.js
- D:\Program Files\path\to\my\application\index.js stopped running.
- Restarted 1250 msecs after unexpected exit; attempts = 1
- D:\Program Files\path\to\my\application\index.js stopped running.
- Restarted 1562.5 msecs after unexpected exit; attempts = 2
- Child process [5800 - D:\Program Files\nodejs\node.exe --harmony "D:\Program Files\otherApps\create-windows-service-for-nodejs\node_modules\node-windows\lib\wrapper.js" --file "D:\Program Files\path\to\my\application\index.js" --log "Node.js Service Management API wrapper" --grow 0.25 --wait 1 --maxrestarts 3 --abortonerror
Here's my implementation of node-windows:
var Service = require('node-windows').Service;
var svc = new Service({
name:'Node.js Service Management API',
description: 'The nodejs.org service management api.',
script: 'D:\\Program Files\\nodeApps\\service-management-api\\server\\server.js'
});
svc.on('install',function(){
svc.start();
console.log('Install complete');
console.log('The service exists: ', svc.exists)
});
svc.install();
Any suggestions on how to fix this service so it stays 'on'? Is it my implementation of node-windows? Or perhaps some windows server 2012 configuration issue?
Thank you!