Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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]
respawn
expect fork
script
  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.

share|improve this question
add comment

migrated from stackoverflow.com Sep 7 '12 at 23:54

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
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
add comment

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.