Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a daemon in /opt/xyz/bin/xyz. Unfortunately it cannot fork itself into background and will not be able to do so within the next half year. My problem is the following: Entering

service xyz start

just returns

xyz start/running, process 23484

Always, even when it immediately exits with exit code 1. My config is this:

$ cat /etc/init/xyz.conf
description "XYZ"

start on started networking
stop on shutdown

exec /opt/xyz/bin/xyz

The rest works fine. Upstart recognizes when the process is already started, stopping works fine too.

Any suggestions?

share|improve this question
up vote 1 down vote accepted

You need a post-start stanza which will query the service as to whether or not it is providing whatever service it is expected to be running. So something like

post-start script
  for try in 1 2 3 4 5 ; do
    if xyzadmin --ping ; then
      exit 0
    sleep 1
  logger -t xyz-upstart -p daemon.err "failed to start within $try seconds, aborting"
  exit 1
end script

When adding the ability to daemonize your service, if at all possible, make sure that it does not fork until it is ready to handle requests, then 'expect fork' will delay the 'started' condition properly, otherwise you will still need this post-start.

share|improve this answer
Great trick, thank you! – user694971 Jan 17 '12 at 9:18

Your Answer


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.