Thursday 14 July 2011

RhodeCode MacOSX Daemon/launchd

I wanted to make RhodeCode run as a launchd daemon process on MacOSX. This isn't as straight forward as it should be.
I made the following file in /Library/LaunchDaemons/rhodecode.plist




  EnvironmentVariables
  
    PYTHON_EGG_CACHE
    /opt/mercurial/.python-eggs
    CELERYD_PID_DIR
    /var/run
  

 GroupName
 daemon
 KeepAlive
 
 Label
 org.rhodelist
 ProgramArguments
 
  /usr/local/bin/paster
  serve
  /opt/mercurial/production.ini
 
 RunAtLoad
 
 UserName
 daemon
 


Restarting with the following commands:
launchctl unload -w /Library/LaunchDaemons/rhodecode.plist
launchctl load -w /Library/LaunchDaemons/rhodecode.plist

I also made a terrible hack to part of RhodeCode to force it to work under launchd (I may write a proper patch at some point in the future).
Line 40 of /Library/Python/2.6/site-packages/RhodeCode-1.1.8-py.2.6.egg/rhodecode/lib/pidlock.py
self.pidfile = "/var/run/" + self.pidfile

Yeah it's gross, but I can improve it later.

No comments:

Post a Comment