把本站的 fastcgi driving script 改成:

#!/your/path/to/python

import sys, os
from datetime import datetime
import traceback

try:
    sys.path.insert(0,'/your/path/to/python/package')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'yoursite.settings'
    from django.core.servers.fastcgi import runfastcgi
    runfastcgi(method="prefork", daemonize="false",
            maxrequests=100,
            maxspare=2, minspare=1, maxchildren=5)
except Exception, e:
    logpath = "/your/path/to/traceback.log"
    if os.path.isfile(logpath):
        f = open(logpath, 'a')
    else:
        f = open(logpath, 'w')
    f.write("logged at %s :\n"%datetime.now())
    traceback.print_exc(file=f)
    f.write("log end.\n\n")
    f.close()

# vim: set ft=python ai et nu sw=4 ts=4 tw=79:

看看會不會也有幫助。如果 maxrequests=100 有用的話,crontab 就可以丟掉了。

Posted by yungyuc at 17:53, 0 comment, 0 trackback.
*/20 * * * * killall bad.fcgi

10 隻小孩還嫌少?只給你二十分鐘好活!

近來訪客可能經常看到本站的 500 錯誤畫面,這都是我寫的程式不乖。本人已經縮短 application server 的生命,如果還看到 500,還請向本人舉報。謝謝大家。

Posted by yungyuc at 14:39, 0 comment, 0 trackback.
Change to page (10 entries in each page): 1
© hover year to navigate month: powered by django