我想将我的 Hubot 包装在 Windows 服务中来部署它。
我正在使用node-windows来做到这一点,但我在尝试让它运行 CoffeeScript 文件(这就是 hubot 使用的)时遇到了一些麻烦。
如果我手动运行
> coffee .\node_modules\hubot\bin\hubot
一切正常。
但我无法弄清楚如何从 Node 窗口脚本中调用它。我的尝试如下:
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)
最佳答案
脚本
不是命令,只是文件的路径。您可以通过设置 execPath
环境变量来更改 node-windows 用于运行脚本的可执行文件:https://github.com/coreybutler/node-windows/issues/61#issuecomment-51423542
关于node.js - Hubot Windows 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33558393/