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 <myself@i.com>"

# 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.

danizmax
  • 2,750
  • 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 '11 at 05: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 '11 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 04 '11 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 '11 at 05:11
  • See http://askubuntu.com/questions/14810/from-init-d-to-upstart-is-there-a-bridge – waltinator Oct 12 '11 at 05:18
  • I updated my post with my script. – danizmax Oct 28 '11 at 06:51
  • We may also need the ts3server_startscript – CameronNemo Jun 08 '14 at 15:52

1 Answers1

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.

SpamapS
  • 19,820