CentOSにFastladderをインストールしてみる
CentOS環境にFastladderを導入しました。手順メモ。
標準構成で起動
Railsのバージョンを上げる。
% rails -v Rails 1.2.5 % sudo gem update rails -y % rails -v Rails 2.0.2
必要なライブラリを導入。
% sudo gem install rfeedfinder -y % sudo gem install feed-normalizer -y % sudo gem install opml % sudo gem install mongrel -y % sudo gem install sqlite3-ruby
FreeImageを導入。
% wget http://downloads.sourceforge.net/freeimage/FreeImage3100.zip % unzip FreeImage3100.zip % cd FreeImage % make % sudo make install
ダウンロードして展開。
% wget http://fastladder.org/downloads/fastladder-0.0.2-src.tar.gz % tar xvfz fastladder-0.0.2-src.tar.gz % cd fastladder
ひとまず起動。
% RAILS_ENV=production rake db:migrate % script/server -d -e production % RAILS_ENV=production script/crawler > /dev/null &
終了。
% pkill -f fastladder % pkill -KILL -f crawler
crawlerはkill -KILLしないと終了しない。
killで終了させたい場合は、以下のようにscript/crawlerの107行目以降を修正する。
修正前
if options[:daemon] WEBrick::Daemon.start do MyCrawler.start(options) end else MyCrawler.start(options) end
修正後
if options[:daemon] WEBrick::Daemon.start do Signal.trap(:TERM){exit(0)} MyCrawler.start(options) end else MyCrawler.start(options) end
% RAILS_ENV=production script/crawler -d # 起動 % pkill -f crawler # 終了
Mysqlで動かす
productionをMysqlで動かすように設定します。
まずは、config/database.ymlを以下のように修正。
production: adapter: mysql database: fastladder_production username: fastladder password: password socket: /var/lib/mysql/mysql.sock host: localhost encoding: utf8
Mysqlにデータベースとユーザを作成します。
mysql> CREATE DATABASE fastladder_production; mysql> grant all privileges on fastladder_production.* to fastladder@localhost identified by 'password';
DB再構築。
% RAILS_ENV=production rake db:migrate
以上で設定完了。起動してみます。
% script/server -d -e production % RAILS_ENV=production script/crawler -d