肩凝り辛い。

今朝起きたら肩凝りが。起きたらヒヤッとして寒いのも関係あるのかもなぁ。風呂入って出かけるか。

fcgidがうまくいかん。

[Mon Mar 31 01:34:50 2008] [notice] mod_fcgid: server /var/www/hoge/hiki.fcgi(9769) started
[Mon Mar 31 01:34:59 2008] [info] mod_fcgid: Read data error, fastcgi server has close connection
[Mon Mar 31 01:34:59 2008] [error] [client xxx.xxx.xxx.xxx] Premature end of script headers: hiki.fcgi, referer: http://yyy.yyy.yyy.yyy/hoge/hiki.fcgi?c=search
[Mon Mar 31 01:35:03 2008] [notice] mod_fcgid: process /var/www/hoge/hiki.fcgi(9769) exit(communication error), terminated by calling exit(), return code: 1

何で、Read data errorを起こすのかを調べなあかんな。

Hikiのセットアップ

あとでsuEXECで動かすのに、専用のユーザを作成。

$ sudo adduser --system --home /var/www/hoge --no-create-home --disabled-login hogehoge

hikisetupを実行すると、失敗した。

$ sudo -u hogehoge /usr/bin/hikisetup
INFO: hiki basedir is /var/www/hoge
Please input data_path [/var/www/hoge/data]:
Error: private method `makedirs' called for File:Class
hikisetup failed!

ここ を参考にしてhikisetupを修正。

$ rcsdiff -r1.2 -r1.1 ./hikisetup
===================================================================
RCS file: ./RCS/hikisetup,v
retrieving revision 1.2
retrieving revision 1.1
diff -r1.2 -r1.1
140c140
<     makedirs(@hikidir)
---
>     File.makedirs(@hikidir)

hikiconf.rb.sampleを作成する。

$ cd /usr/share/doc/hiki/examples
$ sudo gzip -d hikiconf.rb.sample.ja.gz
$ sudo mv -i hikiconf.rb.sample.ja hikiconf.rb.sample

もう一回作り直し。

$ sudo -u hogehoge /usr/bin/hikisetup
INFO: hiki basedir is /var/www/hoge
Please input data_path [/var/www/hoge/data]:
hikisetup succeeded!
Please edit /var/www/hoge/hikiconf.rb

パーミッションの変更

$ sudo chmod -R go+w data

次に、RAAからfcgiwrapをダウンロードしてくる。

$ wget http://rubyforge.org/frs/download.php/34207/fcgiwrap-0.1.6.tgz
$ tar zxf fcgiwrap-0.1.6.tgz
$ sudo cp -i fcgiwrap-0.1.6/lib/fcgiwrap.rb /usr/lib/ruby/1.8/

ラッパー用のスクリプトを作成。

$ cd /var/www/hoge
$ sudo -u hogehoge bash -c 'cat << EOF hiki.fcgi
> #!/usr/bin/ruby
> require 'fcgiwrap'
> FCGIWrap.each {
>   load '/var/www/hoge/hiki.cgi'
> }
> EOF
'
$ sudo chmod 755 hiki.fcgi

Apacheの設定を変更する。hikiconfを読み込めないようにするのと、RewriteルールとFollowSymLinksを追記する。 1

$ cd /etc/apache2/site-available
$ sudo a2enmod rewrite

default を任意のエディタで下記のように変更する。

# (snip)
        <Directory "/var/www/hoge/">
                Options ExecCGI FollowSymLinks
                AllowOverride all
                Order allow,deny
                Allow from all
                <Files "hikiconf.rb">
                        deny from all
                </Files>
                RewriteEngine on
                RewriteBase /hoge/
                RewriteRule ^hiki.cgi(.*)$ hiki.fcgi$1
                RewriteRule ^hiki.cgi$ hiki.fcgi
        </Directory>
# (snip)

これで、hiki.cgiでアクセスしても、hiki.fcgiへ書き換えられ、hiki.fcgiでラッパーしたhiki.cgiが呼ばれるように取り合えずはなりましたよ、と。ただ、fcgidが毎回communication errorを起こし、Internal Server Errorになり、リロードしなおさないとダメ、という状態で使い物にならないので、まだ改善の余地ありだな。

1

Rewrite関連の設定だけだと、”Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /var/www/hoge/”というエラーが出るので。

Apache2.2 + fcgid + rubyを試してみる。

WebサーバをSargeからEtchに移行するにあたり、PukiWikiに比べ、Hikiの方が速いというのを見かけたので、検証してみることにした。で、まずその前に、Apache2.2 + fcgid + Rubyで動くようにしたのでメモ。

EtchがTestingの時に、仮想化友の会でOSCで配布するためにRuby on Rails on DebianのVMwareイメージを作ったが、あの時に比べたら、fcgid + Rubyでやるのは非常に楽ちんになりましたな。

パッケージの導入。

$ sudo apt-get install libfcgi-ruby1.8 libapache2-mod-fcgid hiki tdiary-theme \
libopenssl-ruby1.8 apache2-mpm-worker
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
  apache2-utils apache2.2-common libapr1 libaprutil1 libexpat1 libfcgi0c2 libpcre3 \
libpq4 libruby1.8 libsqlite3-0 libuconv-ruby1.8 mime-support ruby ruby1.8
Suggested packages:
  apache httpd libimage-size-ruby1.8 librd-ruby1.8 ruby1.8-examples rdoc1.8 ri1.8 tdiary
The following NEW packages will be installed:
  apache2-mpm-worker apache2-utils apache2.2-common hiki libapache2-mod-fcgid libapr1 \
libaprutil1 libexpat1 libfcgi-ruby1.8 libfcgi0c2 libopenssl-ruby1.8
  libpcre3 libpq4 libruby1.8 libsqlite3-0 libuconv-ruby1.8 mime-support ruby ruby1.8 tdiary-theme
0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded.
Need to get 7502kB of archives.
After unpacking 25.2MB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://cdn.debian.or.jp etch/main mime-support 3.39-1 [30.9kB]
Get:2 http://cdn.debian.or.jp etch/main libapr1 1.2.7-8.2 [113kB]
Get:3 http://cdn.debian.or.jp etch/main libexpat1 1.95.8-3.4 [67.5kB]
Get:4 http://cdn.debian.or.jp etch/main libpq4 8.1.11-0etch1 [280kB]
Get:5 http://security.debian.org etch/updates/main libpcre3 6.7+7.4-3 [198kB]
Get:6 http://cdn.debian.or.jp etch/main libsqlite3-0 3.3.8-1.1 [194kB]
Get:7 http://cdn.debian.or.jp etch/main libaprutil1 1.2.7+dfsg-2 [72.1kB]
Get:8 http://cdn.debian.or.jp etch/main apache2-utils 2.2.3-4+etch4 [353kB]
Get:9 http://cdn.debian.or.jp etch/main apache2.2-common 2.2.3-4+etch4 [1035kB]
Get:10 http://cdn.debian.or.jp etch/main apache2-mpm-worker 2.2.3-4+etch4 [431kB]
Get:11 http://cdn.debian.or.jp etch/main libruby1.8 1.8.5-4etch1 [1590kB]
Get:12 http://cdn.debian.or.jp etch/main ruby1.8 1.8.5-4etch1 [219kB]
Get:13 http://cdn.debian.or.jp etch/main ruby 1.8.2-1 [19.0kB]
Get:14 http://cdn.debian.or.jp etch/main libuconv-ruby1.8 0.4.12-2 [107kB]
Get:15 http://cdn.debian.or.jp etch/main hiki 0.8.6-1etch1 [228kB]
Get:16 http://cdn.debian.or.jp etch/main libapache2-mod-fcgid 1:1.10-2 [37.9kB]
Get:17 http://cdn.debian.or.jp etch/main libfcgi0c2 2.4.0-6 [281kB]
Get:18 http://cdn.debian.or.jp etch/main libfcgi-ruby1.8 0.8.7-3+b1 [17.2kB]
Get:19 http://cdn.debian.or.jp etch/main libopenssl-ruby1.8 1.8.5-4etch1 [294kB]
Get:20 http://cdn.debian.or.jp etch/main tdiary-theme 2.0.2+20060303-5 [1920kB]
Fetched 7502kB in 13s (539kB/s)
Selecting previously deselected package libpcre3.
(Reading database ... 10076 files and directories currently installed.)
Unpacking libpcre3 (from .../libpcre3_6.7+7.4-3_powerpc.deb) ...
Selecting previously deselected package mime-support.
Unpacking mime-support (from .../mime-support_3.39-1_all.deb) ...
Selecting previously deselected package libapr1.
Unpacking libapr1 (from .../libapr1_1.2.7-8.2_powerpc.deb) ...
Selecting previously deselected package libexpat1.
Unpacking libexpat1 (from .../libexpat1_1.95.8-3.4_powerpc.deb) ...
Selecting previously deselected package libpq4.
Unpacking libpq4 (from .../libpq4_8.1.11-0etch1_powerpc.deb) ...
Selecting previously deselected package libsqlite3-0.
Unpacking libsqlite3-0 (from .../libsqlite3-0_3.3.8-1.1_powerpc.deb) ...
Selecting previously deselected package libaprutil1.
Unpacking libaprutil1 (from .../libaprutil1_1.2.7+dfsg-2_powerpc.deb) ...
Selecting previously deselected package apache2-utils.
Unpacking apache2-utils (from .../apache2-utils_2.2.3-4+etch4_powerpc.deb) ...
Selecting previously deselected package apache2.2-common.
Unpacking apache2.2-common (from .../apache2.2-common_2.2.3-4+etch4_powerpc.deb) ...
Selecting previously deselected package apache2-mpm-worker.
Unpacking apache2-mpm-worker (from .../apache2-mpm-worker_2.2.3-4+etch4_powerpc.deb) ...
Selecting previously deselected package libruby1.8.
Unpacking libruby1.8 (from .../libruby1.8_1.8.5-4etch1_powerpc.deb) ...
Selecting previously deselected package ruby1.8.
Unpacking ruby1.8 (from .../ruby1.8_1.8.5-4etch1_powerpc.deb) ...
Selecting previously deselected package ruby.
Unpacking ruby (from .../archives/ruby_1.8.2-1_all.deb) ...
Selecting previously deselected package libuconv-ruby1.8.
Unpacking libuconv-ruby1.8 (from .../libuconv-ruby1.8_0.4.12-2_powerpc.deb) ...
Selecting previously deselected package hiki.
Unpacking hiki (from .../hiki_0.8.6-1etch1_all.deb) ...
Selecting previously deselected package libapache2-mod-fcgid.
Unpacking libapache2-mod-fcgid (from .../libapache2-mod-fcgid_1%3a1.10-2_powerpc.deb) ...
Selecting previously deselected package libfcgi0c2.
Unpacking libfcgi0c2 (from .../libfcgi0c2_2.4.0-6_powerpc.deb) ...
Selecting previously deselected package libfcgi-ruby1.8.
Unpacking libfcgi-ruby1.8 (from .../libfcgi-ruby1.8_0.8.7-3+b1_powerpc.deb) ...
Selecting previously deselected package libopenssl-ruby1.8.
Unpacking libopenssl-ruby1.8 (from .../libopenssl-ruby1.8_1.8.5-4etch1_powerpc.deb) ...
Selecting previously deselected package tdiary-theme.
Unpacking tdiary-theme (from .../tdiary-theme_2.0.2+20060303-5_all.deb) ...
Setting up libpcre3 (6.7+7.4-3) ...

Setting up mime-support (3.39-1) ...

Setting up libapr1 (1.2.7-8.2) ...

Setting up libexpat1 (1.95.8-3.4) ...

Setting up libpq4 (8.1.11-0etch1) ...

Setting up libsqlite3-0 (3.3.8-1.1) ...

Setting up libaprutil1 (1.2.7+dfsg-2) ...

Setting up apache2-utils (2.2.3-4+etch4) ...
Setting up apache2.2-common (2.2.3-4+etch4) ...
Setting Apache2 to Listen on port 80. If this is not desired, please edit \
/etc/apache2/ports.conf as desired. Note that the Port directive no longer works.
Module alias installed; run /etc/init.d/apache2 force-reload to enable.
Module autoindex installed; run /etc/init.d/apache2 force-reload to enable.
Module dir installed; run /etc/init.d/apache2 force-reload to enable.
Module env installed; run /etc/init.d/apache2 force-reload to enable.
Module mime installed; run /etc/init.d/apache2 force-reload to enable.
Module negotiation installed; run /etc/init.d/apache2 force-reload to enable.
Module setenvif installed; run /etc/init.d/apache2 force-reload to enable.
Module status installed; run /etc/init.d/apache2 force-reload to enable.
Module auth_basic installed; run /etc/init.d/apache2 force-reload to enable.
Module authz_default installed; run /etc/init.d/apache2 force-reload to enable.
Module authz_user installed; run /etc/init.d/apache2 force-reload to enable.
Module authz_groupfile installed; run /etc/init.d/apache2 force-reload to enable.
Module authn_file installed; run /etc/init.d/apache2 force-reload to enable.
Module authz_host installed; run /etc/init.d/apache2 force-reload to enable.

Setting up apache2-mpm-worker (2.2.3-4+etch4) ...
Starting web server (apache2)....

Setting up libruby1.8 (1.8.5-4etch1) ...

Setting up ruby1.8 (1.8.5-4etch1) ...
Setting up ruby (1.8.2-1) ...
Setting up libuconv-ruby1.8 (0.4.12-2) ...
Setting up hiki (0.8.6-1etch1) ...
Setting up libapache2-mod-fcgid (1.10-2) ...
Module fcgid installed; run /etc/init.d/apache2 force-reload to enable.

Setting up libfcgi0c2 (2.4.0-6) ...

Setting up libfcgi-ruby1.8 (0.8.7-3+b1) ...
Setting up libopenssl-ruby1.8 (1.8.5-4etch1) ...
Setting up tdiary-theme (2.0.2+20060303-5) ...

Apacheの設定

  • /etc/apache2/sites-available/defaultの設定。

下記を追加。

<VirtualHost *>
     ServerAdmin webmaster@hoge.com

     DocumentRoot /var/www/
(snip)
        Alias /hoge/ "/var/www/hoge/"
        <Directory "/var/www/hoge/">
                Options ExecCGI
                AllowOverride all
                Order allow,deny
                Allow from all
        </Directory>
(snip)
</VirtualHost>
  • Apacheの再起動。

$ sudo apache2 -t
Syntax OK
$ sudo /etc/init.d/apache2 reload
  • /var/log/apache2/error.logに下記のようにロギングされればOK。

[Sun Mar 30 14:36:39 2008] [notice] mod_fcgid: server /var/www/hoge/hoge.rb(3191) started

腕時計忘れた。

ギリギリまで寝て、慌てて出かけたら、何か忘れたと思ったら腕時計忘れてた。チョー不便。

何かをし忘れるのは、アクションスキーマをショートカットしてしまうだけで失敗したわけではないからスリップでもミステイクでもなくてラプスだということなんだが、これの定義はあっているのだろうか。ワシ、間違って解釈して覚えてないかな。

確かに腕時計を忘れただけなら、携帯電話やパソコンの時計などで代替できるから、失敗ではないと言えると思う。

でも何かの変更作業の際に確認手順が抜けてしまったら、失敗が事故に繋がるよな、と書いていたら、頭の中を整理出来た。おー、そういう事か。

そもそも変更作業するなら、最低限必要な手順は事前に変更申請に落とす。何らかの作業項目に対する確認作業なら、その作業項目~確認作業までがスキーマになっているのが普通だから、確認作業だけが抜けてしまったら、それはラプスではなくてスリップだな。

一方で、そのスキーマである作業項目自体が抜けてしまったら、ラプスなんだろうか?この辺りかなり微妙だな。スキーマのの中のステップが少なすぎるとスリップになるだろうし、多いと丸ごとし忘れるから、失敗にはならないだろうからラプスだろうし。

とは言え、ラプスであっても、ビジネス要件のRFCに基づく変更作業なら、し忘れるとリリース日が遅れてしまうから、事故には繋がらなくても失敗であることには変わりないので、結局はラプスだろうとスリップだろうと、打てる対策には大差無いよなぁ、というのが本日の結論。