Hubot windows服务

问题描述:

我想将我的Hubot包装在一个windows服务中进行部署。Hubot windows服务

我正在使用node-windows来做到这一点,但我在尝试让它运行咖啡脚本文件(这是hubot使用的)时遇到了一些麻烦。

如果我手动运行

> coffee .\node_modules\hubot\bin\hubot 

一切工作正常。

但我无法解决如何从节点窗口脚本调用此。我下面尝试:

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(); 

其失败,出现以下:

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)

+0

您是否尝试过使用永远运行它(https://github.com/foreverjs/forever) 是否有严格的依赖性来运行它作为一项服务,所以你可以运行它作为一个特定的用户? –

script不是命令,只是文件路径。您可以更改使用节点窗口通过设置execPath环境变量来运行脚本可执行:https://github.com/coreybutler/node-windows/issues/61#issuecomment-51423542