% plackup -s Starman app.psgi
と
% starman app.psgi
は、機能的には全く同じ。なんだけど、plackup 使ったほうは ps コマンドでプロセスみるとコマンドラインから渡したパラメーターが見えなくなる。たとえば、worker の数調整して --daemonize したとする。
% plackup -s Starman --workers 2 --daemonize app.psgi
% ps x | grep starman
18801 ?? Ss 0:00.01 starman master
18803 ?? S 0:00.00 starman worker
18804 ?? S 0:00.00 starman worker
こんな表示。一方 starman コマンド使ったほう。
% starman --workers 2 --daemonize app.psgi
% ps x | grep starman
18835 ?? Ss 0:00.01 starman master --workers 2 --daemonize app.psgi
18837 ?? S 0:00.00 starman worker --workers 2 --daemonize app.psgi
18838 ?? S 0:00.00 starman worker --workers 2 --daemonize app.psgi
引数見えてる。
1つのホストで複数のアプリを plackup 経由で動かしていて、さてアプリ更新しよ、HUP だ、ってときに
% ps x | grep starman
したら、いっぱい出てきて焦った...。
それぞれのアプリでもちろん listen してる port も違ったけど、--pid で pid ファイル作っていたので、そっちから、kill して難を逃れた...。
% kill -HUP $(cat hello.pid)
きょうびのイケてる人達は daemontools 使って、plackup なり starman なりなんなり動かしてるようなので、たぶん問題ないんだろうけど( daemontools まだ使った事ないからよくわからん...>< )、コマンド用意されている PSGI なサーバーはとりあえずそれを使おうと思った。
ていうかなんで ps がああなるかわかっていないのはダメ男な気がする...。アウチ。
まったく見当はずれかもしれないけど、"plackup -s"を使うと特別な方法で別スレッドとして起動しているとか?
その際に"starman"への引数を隠しているって事かなと。(どう実装しているかはわかりませんが)
一度、"ps xf | less"あたりでスレッドの親子関係を見てみると良いかも。
Posted by: Hatsuhito UENO | Mar 30, 2010 at 10:03