node.js - Hubot Windows 服务

标签 node.js coffeescript hubot node-windows

我想将我的 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/

相关文章:

mysql - 将表情符号保存到 MYSQL DB

javascript - Rails 什么时候编译 CoffeeScript?

node.js - 如何为 hubot 设置 node_path

coffeescript - 如何找到 Hubot 正在响应的房间的名称?

php - 如何保护 Node App 免受直接访问和安装 Node 的正确方法

node.js - 使用 supertest 设置超时不起作用

c# - Node JS 运行一个 c# 程序

javascript - 如何在 CoffeeScript 中新定义的函数上调用函数

javascript - jQuery 的 .done() 和 .always() 永远不会被调用

javascript - 清除 hubot 上的计时器重新加载所有脚本