11

I'm trying to make a simple upstart script for teamspeak server, but can't make it work.

When I say initctl start it just executes but never finishes or even emits any message. Same is happening for stop.

To be sure I am not doing anything wrong, I have copied the cron script and tried to run it, but it happens the same.

what am I doing wrong here?

UPDATE:

here is my script for TS3:

# myservice - myservice job file
description "my service description"
author "Me <[email protected]>"

# Stanzas
#
# Stanzas control when and how a process is started and stopped
# See a list of stanzas here: http://upstart.ubuntu.com/wiki/Stanzas#respawn

# When to start the service
start on runlevel [2345]

# When to stop the service
stop on runlevel [016]

# Automatically restart process if crashed
respawn

# Essentially lets upstart know the process will detach itself to the background
expect fork

# Start the process
script
       emit going into TS3 dir
       chdir /home/danizmax/teamspeak3-server_linux-x86/
       emit starting TS3
       exec su -c "/home/danizmax/teamspeak3-server_linux-x86/ts3server_startscript.sh start" danizmax &
       emit done
end script

I tried even with simplest script, and that also doesn't work:

description     "regular background program processing daemon"

start on runlevel [2345]
stop on runlevel [!2345]

expect fork
respawn

exec echo example
console output

Thank you for your help.

7
  • You might want to show the upstart job you're trying to run so that we can debug it? Hard to know why it's hanging without seeing it.
    – slangasek
    Sep 28, 2011 at 5:48
  • I have copied the cron script and tried to run it and it happens the same, just stops and never returns to the shell
    – danizmax
    Sep 29, 2011 at 20:18
  • We still need to see your upstart script. Without it, there is nothing we can do. Please post it, or provide us with a link to it.
    – hggdh
    Oct 4, 2011 at 23:35
  • Without seeing the script, all I can do is guess: Does your script care that it's run as root by upstart? Root's PATH is different. If your script wants to use an application that's not in in root's PATH you must specify the full path. Is there a prog in your script that doesn't return?
    – waltinator
    Oct 12, 2011 at 5:11
  • See askubuntu.com/questions/14810/…
    – waltinator
    Oct 12, 2011 at 5:18

1 Answer 1

1

there are a number of oddities in your upstart job that have me scratching my head.

1) emit isn't a program that I know of, so unless you've added it to the system path, that is probaly causing errors. Did you mean 'echo' ? That may not be helpfull either, since it will go to the system console which may not be visible.

2) Assuming the 'emit' stanza works, you say 'expect fork' but then actually fork twice. Once for the 'script', and then again when the teamspeak script forks to background itself.

3) you "su" to run the script, but start-stop-daemon is actually simpler for most cases:

With 11.10, you don't need to do the chdir in script, not sure if that was added after whatever version of upstart you have. Check man 5 init for the word chdir

start on runlevel [2345]
stop on runlevel [^2345]

respawn

chdir /home/danizmax/teamspeak-server
expect fork

exec start-stop-daemon --start --user danizmax --group danizmax --exec /home/danizmax/teamspeak3-server_linux-x86/ts3server_startscript.sh -- start

Also, errors will likely be reported in /var/log/syslog . You can increase the error level quite a bit by running

initctl log-priority info

man initctl for more log levels.

2
  • Not the OP, but he is using (danimaz) su to execute the server as his user, not to become root. Oct 31, 2011 at 9:39
  • Hah doh, missed the scroll bar on the bottom.. perfectly aligned to hide the username. :-P
    – SpamapS
    Nov 6, 2011 at 3:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .