趣味のサーバいじりへの復帰第一弾として、この日記をunicorn+nginxで動くようにしてみた。
nginxの起動スクリプトはhttp://wiki.nginx.org/Upstartをほぼそのまま使う。
# nginx
description "nginx http daemon"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/opt/nginx/sbin/nginx
expect fork
respawn
respawn limit 10 5
pre-start script
$DAEMON -t
if [ $? -ne 0 ]
then exit $?
fi
end script
exec $DAEMON -c /opt/nginx/conf/nginx.conf
unicornは、start on startingとstop on stoppedを使ってnginxと連動させてみた。execの前にLANGをUTF-8に設定しておかないと、tdiaryがうまく動かない。設定しない状態だとtdiary.confの中のマルチバイト文字をうまく取り扱えないみたい。
description "unicorn"
start on starting nginx
stop on stopped nginx
respawn
script
export LANG=ja_JP.UTF-8
exec /usr/local/bin/unicorn -c /path/to/tdiary-core/unicorn.conf
end script