开发者

Pylons on OS X: proper launchd plist to start and keep alive pylons server?

Update: It was simply an import error in the Pylons app (because $PYTHONPATH is different when running a launchd job) that was causing a fail-respawn cycle. Many thanks for those who told me to look at my logs.

Hi all,

I'm on OS X, trying to set up a launchd job to start and keep alive my pylons application.

I load the job as usual:

sudo launchctl unload /Library/LaunchDaemons/dvlf.plist

I see no errors in the terminal. The server never comes up. Instead I see this on the console:

4/12/11 6:23:57 PM  com.apple.launchd[1]    (com.dvlf.pylons) Throttling respawn: Will start in 9 seconds

Here's the .plist file. Any ideas are greatly appreciated!

<?xml version="1.0" encodi开发者_如何学JAVAng="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Disabled</key>
    <false/>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>com.dvlf.pylons</string>
    <key>EnvironmentVariables</key>
        <dict>
                <key>PYTHON_EGG_CACHE</key>
                <string>/tmp/.python-eggs</string>
        </dict>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/paster</string>
        <string>serve</string>
        <string>--reload</string>
        <string>/Volumes/w/artfl/projects/dodgr/servers/pylons/DODGR/production.ini</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>Umask</key>
    <integer>7</integer>
    <key>UserName</key>
    <string>_www</string>
    <key>WorkingDirectory</key>
    <string>/Volumes/w/artfl/projects/dodgr/servers/pylons/DODGR/</string>
    <key>StandardErrorPath</key>
    <string>/var/log/dvlf_paster_error.log</string>
    <key>StandardOutPath</key>
    <string>/var/log/dvlf_output.log</string>
</dict>
</plist>


When I've seen "respawning too fast" on SysV init systems (/etc/inittab entries) it's been because the program in question was using the traditional "double fork, then exec" strategy to become a daemon. Many such programs (such as sshd and sylogd) support command line switches (-D for sshd, for example) which instruct them to refrain from fork()-ing.

The problem is that init (and presumably launchd) are attempting to monitor the process in order to handle respawning them if/when they exit. When the program attempts to put itself in the background (disconnect itself from the parent process, process group, and all related signal handling) then this is detected as a near immediate exit which requires the respawn. inittab (and, again, presumably launchd) are imposing rate limiting to keep one failing program from keeping the system excessively busy.

The solution to this issue see if you can configure this dvlfs.pylons program to run in the foreground or "don't detach" or "don't daemonize" ... terminology to that effect.


The respawn message usually occurs because the process crashed shortly after startup, probably because bad configuration. So, check your logfiles.

From the plist: do you really have these dirs/files? (check all path in your plist - the most common error)

/Volumes/w/artfl/projects/dodgr/servers/pylons/DODGR/production.ini
/Volumes/w/artfl/projects/dodgr/servers/pylons/DODGR/

if not, you should re-edit your plist.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜