1

I would like to wrap my Hubot in a windows service to deploy it.

I am using node-windows to do this but I'm having some trouble trying to get it to run a coffee-script file (which is what hubot uses).

If i manually run

> coffee .\node_modules\hubot\bin\hubot

everything works fine.

But I cant work out how to call this from a node-windows script. My attempt below:

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

var svc = new Service({
  name:'Hubot',
  description: 'Hubot',
  script: 'coffee .\\hubot\\node_modules\\hubot\\bin\\hubot'
});

svc.on('install',function(){
  svc.start();
});

svc.install();

which fails with the following:

C:\Users\luke.mcgregor\hubot>node app.js fs.js:747 return binding.mkdir(pathModule._makeLong(path), ^ Error: ENOENT, no such file or directory 'C:\Users\luke.mcgregor\hubot\coffee .\hubot\node_modules\hubot\bin\daemon' at Error (native) at Object.fs.mkdirSync (fs.js:747:18) at C:\Users\luke.mcgregor\AppData\Roaming\npm\node_modules\node-windows\lib\daemon.js:409:16 at FSReqWrap.cb [as oncomplete] (fs.js:226:19)

undefined
  • 33,537
  • 22
  • 129
  • 198
  • Have you tried using forever to run it (https://github.com/foreverjs/forever) Is there a rigid dependency to run it as a service so you can run it as a specific user? – john.da.costa Nov 19 '15 at 00:16

1 Answers1

1

The script is not a command, only the path to a file. You can change the executable used by node-windows to run your scripts by setting an execPath environment variable: https://github.com/coreybutler/node-windows/issues/61#issuecomment-51423542

Shanoor
  • 13,344
  • 2
  • 29
  • 40