hubot-thumb-680x322-2165-thumb-680x322-1510

foreverを使ってhubot-slackをデーモン化して使っています。すると1週間~2週間程度連続稼働させるといつの間にかhubotが要求を受け付けなくなる事象に遭遇しておりました。

たまたまというものではなく、定期的に発生するようなので何らかの問題があることは間違いなさそうです。

OSはCENTOSです。

調べたところ、foreverのログにはこのようなメッセージが。

Mon Sep 26 2016 20:37:54 GMT+0900 (JST)] ERROR Last pong is too old: 14.838
[Mon Sep 26 2016 20:37:54 GMT+0900 (JST)] INFO Reconnecting in 1000ms
[Mon Sep 26 2016 20:37:55 GMT+0900 (JST)] INFO Attempting reconnect
[Mon Sep 26 2016 20:37:55 GMT+0900 (JST)] INFO Connecting...
[Mon Sep 26 2016 20:37:58 GMT+0900 (JST)] INFO Logged in as hubot of XXX, but not yet connected
[Mon Sep 26 2016 20:37:58 GMT+0900 (JST)] INFO Slack client now connected
[Mon Sep 26 2016 20:38:24 GMT+0900 (JST)] INFO Slack client connection was closed, exiting hubot process
error: Forever detected script exited with code: 1
error: Script restart attempt #10
[Mon Sep 26 2016 20:38:28 GMT+0900 (JST)] INFO Connecting...
[Mon Sep 26 2016 20:38:30 GMT+0900 (JST)] INFO Logged in as hubot of XXX, but not yet connected
[Mon Sep 26 2016 20:39:33 GMT+0900 (JST)] ERROR Error: connect ETIMEDOUT

これを見る限り途中で切断されているような感じですかね。

調べたところ、もともと使っていたhubot-slack3.4.2には不具合があるようで、同じようにいきなり停止してしまう不具合が含まれていた模様。

参考

https://github.com/slackhq/hubot-slack/issues/282
https://github.com/slackhq/hubot-slack
https://github.com/edina/edina-hubot/commit/817cef3fe30944aef286fbe41c812282ce287873

下記コマンドでアップデートします。
$npm install hubot-slack –save n –latest

これでpackage.jsonのhubot-slackのバージョンが4.0.2になります。

その後1週間以上経過しておりますが、hubotは止まらなくなりました。

めでたし、めでたし。