I'm trying to set up an Ubuntu (12.04 LTS) upstart script to manage Trac's built in web server as an upstream server for nginx.
Here is my init script /etc/init/tracd.conf
. I used http://codebyko.se/2010/11/26/tracd-with-upstart-on-ubuntu/ (first and only google result for 'upstart' and 'tracd') as a starting point:
description "Tracd Web Server"
start on startup
stop on shutdown
expect daemon
exec sudo tracd -d -p 8000 -b 192.168.1.2 --user=www-data --group=www-data /trac/proj
Whenever I run this through sudo service tracd start
or sudo service tracd stop
, it simply hangs and never returns. sudo service tracd status
returns "tracd start/killed, process 748". The upstart log /var/log/upstart/tracd.log
contains no information, nor does syslog.
If I simply copy and paste sudo tracd -d -p 8000 -b 192.168.1.2 --user=www-data --group=www-data /trac/proj
on the command line, the server runs fine.
Here is what I've tried:
- Googled — hard. Read through Ubuntu's upstart cookbook page and all of the Trac guides: TracInstall, TracNginxRecipe, TracStandalone
- Use
expect fork
,expect daemon
or omit theexpect
line entirely. - Use
script
/end script
block around the exec line. - Use
setuid www-data
/setgid www-data
. - Use
sudo -u www-data
and evensudo su www-data -c "..."
- Created a www-data writable dir
/var/run/trac/
and specified--pidfile=/var/run/trac/tracd.pid
. - Examine output from
sudo -u www-data env
to see if there are any special environment variables from command line, because it's running fine when executed from the shell. Trac doesn't appear to rely on any environment variables. - Used the much more verbose, but identical command:
sudo /usr/bin/python /usr/local/bin/tracd --daemonize --port=8000 --hostname=192.168.1.2 --user=www-data --group=www-data /trac/proj
- Checked for zombie tracd daemons with
ps -aux | grep trac
.
Things I haven't tried:
- Abandon upstart for an init.d script.
EDIT: Fixed
Removing the --daemonize
flag seems to have fixed it. Thanks Mike! Here's my working upstart script:
description "Trac Web Server"
start on startup
stop on shutdown
setuid www-data
setgid www-data
exec tracd -p 8000 -b 192.168.1.2 /trac/proj
Best Answer
I don't think you need the sudo since tracd is setting the user/group
If that doesn't work try to set the running user in upstart via
setuid
andsetgid
EDIT
remove the -d flag.. upstart you cannot run something as a daemon it needs to act like it is running in the foreground