2017-01-13 103 views
0

我正在关注PluralSight有关流浪和hubot懈怠设置的教程。hubot-slack“无法找到模块” - 从新贵只

唯一的区别是我使用hubot-slack。

如果我通过从终端调用hubot脚本启动hubot - 一切正常 - bot连接并响应命令。

不幸的是,当hubot作为一个服务从新贵开始 - 我得到这个登录到/var/log/upstart/myhubot.log`无法加载适配器松弛 - 错误:找不到模块'hubot-slack'

/bin/hubot文件看起来像这样(从CLI中被执行时,这只是正常):这是作为一个服务执行

#!/bin/sh 
set -e 
npm install 
export PATH="node_modules:node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH" 
export HUBOT_SLACK_TOKEN={} 
exec node_modules/.bin/hubot --name "hubot" --adapter slack "[email protected]" 

.conf文件看起来像这样(找不到模块):

description "My hubot" 
author "Me [email protected]" 

start on runlevel [2345] 
stop on runlevel [016] 

setuid vagrant 

env HOME="/home/vagrant" 

chdir /vagrant/my-awesome-hubot 

console log 

script 
    export PATH="node_modules:node_modules/.bin:node_modules/hubot/node_modules/.bin:/usr/bin/coffee:/usr/bin/node:$PATH" 
    export HUBOT_SLACK_TOKEN={} 
    echo "DEBUG: `set`" >> /tmp/myhubot.log 
    exec node_modules/.bin/hubot --name "hubot" --adapter slack 
end script 

respawn 

请记住,从这些脚本中排除松弛标记。 调试显示chdir做的是正确的事情,pwd与我手动执行脚本时完全相同。

我已经尝试删除整个nodejs项目和从头开始与yeoman生成,也尝试安装hubot-slack globaly和本地但无济于事。

如果是.conf文件 - 没有npm安装,但是在provision.sh文件中 - 我正在cd(作为一个流浪用户)到根目录,执行npm install - 然后才重新启动服务。我也确保我之前做清理前一轮测试的一切 - vagrant provision

cp /vagrant/upstart/myhubot.conf /etc/init/myhubot.conf 
sudo -u vagrant -i sh -c 'cd /vagrant/my-awesome-hubot; npm install' 
service myhubot restart 

你有什么建议。

回答

1

我刚刚花了一天的时间解决了同样的问题,因为这个未答复的问题,所以认为我会更新我的解决方案。

当生成hubot的文件夹中,当前hubot生成的应用程序以命令HUBOT_SLACK_TOKEN=xoxb-YOUR-TOKEN-HERE ./bin/hubot --adapter slack以cli启动。因此使用默认的bin/hubot脚本。

你的conf文件,因此需要挑选这件事应该运行以下命令:

description "My hubot" 
author "Me [email protected]" 

start on runlevel [2345] 
stop on runlevel [016] 

script 
    chdir /vagrant/my-awesome-hubot 
    export PATH="node_modules:node_modules/.bin:node_modules/hubot/node_modules/.bin:/usr/bin/coffee:/usr/bin/node:$PATH" 
    HUBOT_SLACK_TOKEN=xoxb-YOUR-TOKEN-HERE ./bin/hubot --adapter slack --name "hubot" >> /tmp/myhubot.log 
end script 

respawn