Comment 1 for bug 920175

Revision history for this message
Clint Byrum (clint-fewbar) wrote : Re: [Bug 920175] [NEW] Drizzled cannot shutdown itself on ubuntu, upstart restarts it

Excerpts from Henrik Ingo's message of Sun Jan 22 21:43:11 UTC 2012:
> Public bug reported:
>
> This seems to be specific to running drizzled under upstart, ie modern
> Ubuntu versions. It happens as installed with the debs that come with
> Ubuntu and also the basis for our future own deb downloads. I don't know
> if this is an error in our upstart script, or upstart itself. In
> particular, should upstart with a respawn directive allow the service to
> shutdown when it exits without error?
>
> The symptom is that "shutdown" given via the client is ineffective /
> becomes a restart.
>
>
> hingo@mermaid:~/hacking/drizzle/deb$ ps aux|grep drizzle
> root 19723 0.0 0.0 2040 508 ? Ss 23:33 0:00 /bin/sh -e -c exec /usr/sbin/drizzled --user drizzle 2>&1 | logger -t drizzle -p daemon.err /bin/sh
> drizzle 19724 0.6 1.9 395252 39592 ? Sl 23:33 0:00 /usr/sbin/drizzled --user drizzle
> root 19725 0.0 0.0 1952 540 ? S 23:33 0:00 logger -t drizzle -p daemon.err
> hingo 19749 0.0 0.0 5656 800 pts/0 S+ 23:33 0:00 grep drizzle
> hingo@mermaid:~/hacking/drizzle/deb$ drizzle --execute="shutdown"
> hingo@mermaid:~/hacking/drizzle/deb$ ps aux|grep drizzle
> root 19752 0.0 0.0 2040 512 ? Ss 23:33 0:00 /bin/sh -e -c exec /usr/sbin/drizzled --user drizzle 2>&1 | logger -t drizzle -p daemon.err /bin/sh
> drizzle 19753 10.0 1.9 387056 38948 ? Sl 23:33 0:00 /usr/sbin/drizzled --user drizzle
> root 19754 0.0 0.0 1952 544 ? S 23:33 0:00 logger -t drizzle -p daemon.err
> hingo 19776 0.0 0.0 5656 796 pts/0 S+ 23:33 0:00 grep drizzle
> hingo@mermaid:~/hacking/drizzle/deb$ sudo service drizzle stop
> drizzle stop/waiting
> hingo@mermaid:~/hacking/drizzle/deb$ ps aux|grep drizzle
> hingo 19836 0.0 0.0 5656 800 pts/0 S+ 23:40 0:00 grep drizzle
> hingo@mermaid:~/hacking/drizzle/deb$
>

Hi Henrik, this makes sense.

We need to define 0 as a normal exit code for drizzle.

man 5 init states that using respawn on a job will cause upstart to respawn
the process unless you change the "goal" of the job to 'stop'. However, you
can also define a normal exit code that will allow the job to transition to
stop.

From man 5 init:

respawn
      A service or task with this stanza will be automatically started
      if it should stop abnormally. All reasons for a service stopping,
      except the stop(8) command itself, are considered abnormal.
      Tasks may exit with a zero exit status to prevent being respawned.

respawn limit COUNT INTERVAL
      Respawning is subject to a limit, if the job is respawned more
      than COUNT times in INTERVAL seconds, it will be considered to be
      hav‐ ing deeper problems and will be stopped. Default COUNT is
      10. Default INTERVAL is 5 seconds.

      This only applies to automatic respawns and not the restart(8)
      command.

normal exit STATUS|SIGNAL...
      Additional exit statuses or even signals may be added, if the
      job process terminates with any of these it will not be considered
      to have failed and will not be respawned.

      normal exit 0 1 TERM HUP