I have written an upstart script called 'ts.conf' for a daemon and put it in /etc/init. When I try to start it with

start ts

I expect a confirmation message and I also expect to get the prompt back, but the terminal hangs. When I hit ctrl-c I get the prompt back. If I start again a message says

start: Job is already running: ts

The server is, however, not running, and I can find the mono process using 'ps -ef'.

The script 'ts.conf' is located in /etc/init and looks like this:

start on runlevel [2345]
stop on runlevel [016]
expect fork
  cd /home/ubuntu/Terraria
  /usr/bin/mono /home/ubuntu/Terraria/TerrariaServer.exe -worldpath /home/ubuntu/Terraria -world world1.wld 
end script

The server starts fine if I run the command manually from the command prompt. Can anybody see what is wrong with my upstart script, or understand why nothing seems to happen?

Please not that the text above is WRONG when it says that I can find the process with ps -ef. I CAN NOT find the process using ps.


You likely have multiple problems here:

1) expect fork. Script section keeps waiting for a fork to happen and hangs waiting for it.

2) Server not coming up. Upstart script section is run as root, and lacks all of the environment. You say it works if you paste it on command line, that is because you are not root and you have environment.

If mono is expected to fork for real, then fixing 2 fixes also 1. Otherwise remove expect fork.

See Upstart Cookbook at http://upstart.ubuntu.com/cookbook/#id94 for user jobs, it'll likely solve your problem 2.

  • Yes, thank's, I misunderstood 'expect fork'. Thought I needed it to put my job in the background... – Henrik Sep 24 '12 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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