Ian Lewis
Ian Lewis is a web developer living in Tokyo Japan. His current interests are in Django, python, alternative databases and rapid web application development. About Me...
  • daemontoolsを使ってdjango fastcgiのデーモンを設定する

    daemontoolsの上にdjango fastcgiを使うのは簡単にできるけど、正しいユーザとして、フォアグラウンドに起動するにはbashとdaemontoolsの設定する必要がある。

    フォアグラウンドに起動するには、daemonize=falseを指定する必要がある。

    それで、起動するデイモンはユーザを指定するオプションがないとrootユーザとして、起動する。runfcgi はそういうオプションがないので、daemontools の setuidgid ツールを使う。

    setuidgidのコマンドになるので、プロセスの標準パイプを正しく接続するには、bashのexecコマンドを使う。

    /service/myapp/run

    #!/bin/bash
    
    BASEDIR="/home/www/"
    PIDFILE="$BASEDIR/app.pid"
    
    exec setuidgid www python /home/www/django-prj/manage.py runfcgi \
        --settings=settings_production method=threaded  port=8001 \
        pidfile=$PIDFILE daemonize=false 2>&1
    
    Send feedback このエントリーを含むはてなブックマーク はてなブックマーク - daemontoolsを使ってdjango fastcgiのデーモンを設定する