34
34

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

EC2(Amazon Linux)にHubotを入れて、HipChatでBot化するまで

Last updated at Posted at 2014-05-28

始めにタイムゾーンの設定とアップデート

$ sudo yum update
$ sudo cp /usr/share/zoneinfo/Japan /etc/localtime 

Hubotに必要なパッケージのインストール

$ sudo yum --enablerepo=epel install npm redis

redisの起動

$ sudo /etc/init.d/redis start
redis-server を起動中:	[  OK  ]

coffee-scriptとhubotのインストール

$ sudo npm install -g coffee-script hubot
$ hubot --create mybot
$ cd mybot
$ npm install

hubotの動作確認

$ ./bin/hubot
Hubot> hubot ping
Hubot> PONG
Hubot> exit

hubot-hipchatのインストール

$ sudo yum install libicu-devel
$ npm install hubot-hipchat --save

HipChatで起動するためのスクリプトを作る

~/mybot/内で起動用のスクリプトファイルを作る。

$ vi run.sh
run.sh
#!/bin/bash

export HUBOT_HIPCHAT_JID="jid"
export HUBOT_HIPCHAT_PASSWORD="password"
bin/hubot --adapter hipchat

HUBOT_HIPCHAT_JIDはHipChatにログインした時にある設定項目の、Account Infoのjabber IDの値を設定します。

動作させる

$ sh ./run.sh
[Wed May 28 2014 00:00:00 GMT+0900 (JST)] INFO Connecting HipChat adapter...
[Wed May 28 2014 00:00:00 GMT+0900 (JST)] INFO Connected to hipchat.com as @****
[Wed May 28 2014 00:00:00 GMT+0900 (JST)] WARNING The HUBOT_AUTH_ADMIN environment variable not set
[Wed May 28 2014 00:00:00 GMT+0900 (JST)] INFO Data for brain retrieved from Redis
[Wed May 28 2014 00:00:00 GMT+0900 (JST)] INFO Joining ******_*****@conf.hipchat.com

デーモン化

foreverをインストール

$ sudo npm install forever -g

インストール後、先程作ったrun.shにforeverの記述を追加する

run.sh
#!/bin/bash

export HUBOT_HIPCHAT_JID="jid"
export HUBOT_HIPCHAT_PASSWORD="password"

forever start -c coffee bin/hubot -a hipchat

再度動作させる

$ sh ./run.sh

info: Forever processing file: bin/hubotの様なメッセージが出たら成功!

話しかける

スクリーンショット_2014-05-28_22_04_23.png

やったね!

34
34
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
34

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?