Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 the expect line entirely.
  • Use script/end script block around the exec line.
  • Use setuid www-data/setgid www-data.
  • Use sudo -u www-data and even sudo 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
share|improve this question
    
which version of ubuntu are you using? –  Mike Dec 31 '12 at 2:48
    
Ubuntu 12.04.1 LTS; updated the post. –  jcampbelly Dec 31 '12 at 2:54

1 Answer 1

up vote 2 down vote accepted

I don't think you need the sudo since tracd is setting the user/group

description "Tracd Web Server"

start on startup
stop on shutdown


expect daemon

exec tracd -p 8000 -b 192.168.1.2 --user=www-data --group=www-data /trac/proj

If that doesn't work try to set the running user in upstart via setuid and setgid

description "Tracd Web Server"

start on startup
stop on shutdown

setuid www-data
setgid www-data

expect daemon

exec tracd -p 8000 -b 192.168.1.2 /trac/proj

EDIT

remove the -d flag.. upstart you cannot run something as a daemon it needs to act like it is running in the foreground

share|improve this answer
    
I tried both, but the problem is the fact that the same command (from exec on) works on the shell, but in a service definition, sudo service tracd start or stop just hangs. –  jcampbelly Dec 31 '12 at 4:50
    
ohh i see the problem.. see the edit –  Mike Dec 31 '12 at 5:24
    
so the -d flag needs to be removed.. upstart likes things to run in the foreground. It is hanging probably due to the -d flag –  Mike Dec 31 '12 at 5:25
    
That did the trick! Thanks, man. –  jcampbelly Dec 31 '12 at 5:54
    
glad that was the problem –  Mike Dec 31 '12 at 6:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.