Hubot | forever で Hubot(Hubot-Kandan adapter) をデーモンとして起動する
概要
forever で Hubot-Kandan をデーモンとして起動します。
前提
- 検証環境は Ubuntu 14.04
- node.js, npm はインストール済み
手順
forever のインストール
sudo npm install forever -g
hubot-kandan 起動スクリプトの作成
start_hubot.sh
#!/bin/bash
forever start -c coffee node_modules/.bin/hubot -a kandan
hubot-kandan 停止スクリプトの作成
stop_hubot.sh
#!/bin/bash
forever stop -c coffee node_modules/.bin/hubot
hubot-kandan 再起動スクリプトの作成
restart_hubot.sh
#!/bin/bash
./stop_hubot.sh
./start_hubot.sh
確認
$ cd %hubot%
# Hubot ( hubot-kandan ) を 起動
$ ./start_hubot.sh
info: Forever processing file: node_modules/.bin/hubot
# 起動確認
$ forever list
info: Forever processes running
data: uid command script forever pid logfile uptime
data: [0] oNQH coffee node_modules/.bin/hubot -a kandan 4628 4630 /home/vagrant/.forever/oNQH.log 0:0:0:52.791
# Hubot ( hubot-kandan ) を 起動
$ ./stop_hubot.sh
info: Forever stopped process:
data: uid command script forever pid logfile uptime
[0] oNQH coffee node_modules/.bin/hubot -a kandan 4628 4630 /home/vagrant/.forever/oNQH.log 0:0:2:20.968
# 停止確認
$ forever list
info: No forever processes running
# 再起動の確認のため、 Hubot を起動
$ ./start_hubot.sh
info: Forever processing file: node_modules/.bin/hubot
# 再起動の確認のため、新規の Hubot Script を追加。スクリプトを追加します
$ vi ./scripts/deathma.coffee
# スクリプトの編集内容は下記記事のものを利用します。
# HubotのScriptを自作する - デスマコロシアムのURLを返却するScript
# http://qiita.com/tbpgr/items/7ed860b22ea6c7191111
- 新規追加した script がまだ有効化されていないことをKandanから確認
- Hubotを再起動します
$ ./restart_hubot.sh
info: Forever stopped process:
data: uid command script forever pid logfile uptime
[0] Or0F coffee node_modules/.bin/hubot -a kandan 4676 4678 /home/vagrant/.forever/Or0F.log 0:0:6:54.571
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info: Forever processing file: node_modules/.bin/hubot
- 新規追加した script が有効化されたことをKandanから確認
参照