2008年01月10日(木) [過去の今日]
#1 Reviewable Mind を Debian etch で動かしてみた
essaさんとこ で発表された Reviewable Mind 、略してrmindをDebian etchに突っ込んでみた。
まずはrubyをインストール。
$ aptitude install ruby ruby1.8-dev
んでもってrubygemsを入れるのだが、etchのは古くてうまく動かないので、sidのをもらって来る。
/etc/apt/apt.conf.d/99target に
APT::Default-Release "stable";
と書いておき、/etc/apt/sources.listに以下の行を追加。
# unstable deb http://cdn.debian.or.jp/debian/ sid main contrib non-free
そしてupdateしてinstall。
$ sudo aptitude install rubygems/unstable
etchのrubyライブラリやrailsは古くてrmindを動かせないので、あとはgemで拾ってくる。
$ sudo gem install rpsec --version=1.0.8 $ sudo gem install gettext $ sudo gem install hpricot $ sudo gem install rails --version=1.2.6
rails 2.0系では動かない模様なので、1.2.6をいれる。
んでもって、どこでもいいんだが俺は/usr/local/srcに移動し、
$ svn co http://svn.brain-tokyo.net/rmind/trunk/rmind/ $ cd rmind/vender/plugins $ svn co http://svn.brain-tokyo.net/amrita2/trunk/amrita2/ $ cd ../../ $ cp config/database.yml.sample config/database.yml
ってな感じで本体をひろって、面倒なのでdatabase.ymlはそのまま使用。
んでもってDBの設定。mysqlでプロンプト入って以下のように。
CREATE DATABASE rmind; use rmind; GRANT ALL PRIVILEGES ON rmind.* TO rmind@localhost identified by 'rmind';
んでもってテーブルを作る。
$ rake environment RAILS_ENV=production migrate
これでもう動くはず。
$ ruby script/server
で起動して動作確認。
んでもってapacheから使いたかったのだが、mod_rubyもfastcgiもうまく動かなかったので、mongrelを使ってmod_proxyで飛ばす事に。
$ gem install mongrel
んでmongrelの動作確認。rmindのディレクトリでコマンド打つだけ。
$ mongrel_rails
しかしこれだと端末1個取られちゃうので、デーモンモードで起動する。しかしいちいち起動するのもめんどくさいからinitスクリプトを書いた。
$ cd /etc/init.d $ sudo cp skeleton rmind
んでもってskeltonからコピーしたファイルを以下のようにエディット。ポートとかはおすきなように。
#! /bin/sh # Author: Sugano `Koshian' Yoshihisa(E) <koshian@misao.gr.jp> MONGREL=/usr/bin/mongrel_rails RAILS_ROOT=/usr/local/src/rmind DAEMON=$MONGREL NAME=rmind PORT=13001 # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Reviewable Mind" # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions cd $RAILS_ROOT case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" $MONGREL start -d -p $PORT -e production ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" $MONGREL stop ;; restart|force-reload) $MONGREL restart ;; *) #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 3 ;; esac
編集てけとーなので要らないところもありそう。
んでもって自動起動するように、
$ sudo update-rc.d rmind defaults 90
としておく。
仕上げにapacheの設定。apache2を入れておいて、/etc/apache2/conf.d/rmind というファイルを作って以下のように書いた。
<VirtualHost *> ServerName rmind.example.org ProxyPass / http://localhost:13001/ ProxyPassReverse / http://localhost:13001/ </VirtualHost>
ServerNameは自分のものを適当に。
ということで動作したぜ! これで生産性あげれるといいな。
(@113)