Skip to content

Instantly share code, notes, and snippets.

@c4milo
Created May 18, 2014 18:47
Show Gist options
  • Save c4milo/f6130f1b6873076ae839 to your computer and use it in GitHub Desktop.
Save c4milo/f6130f1b6873076ae839 to your computer and use it in GitHub Desktop.
Upstart script for Ejabberd
# Ubuntu upstart file at /etc/init/ejabberd.conf
respawn
respawn limit 20 5
start on runlevel [2345]
stop on runlevel [06]
script
exec start-stop-daemon --start --name ejabberd --user ejabberd --chuid ejabberd --exec /usr/local/sbin/ejabberdctl -- start
end script
pre-stop script
exec start-stop-daemon --stop --oknodo --signal QUIT --user ejabberd --chuid ejabberd --exec /usr/lib/erlang/erts-5.10.1/bin/beam.smp
end script
@c4milo
Copy link
Author

c4milo commented May 19, 2014

to make this work with Upstart, an additional change is to modify ejabberdctl start function from this:

start ()
{
    checknodenameusage
    [ "$?" -eq 0 ] && echo "\nERROR: The node '$ERLANG_NODE' is already running." && return 1

    $EXEC_CMD "$ERL \
      $NAME $ERLANG_NODE \
      -noinput -detached \
      -pa $EJABBERD_EBIN_PATH \
      -mnesia dir \"\\\"$SPOOLDIR\\\"\" \
      $KERNEL_OPTS \
      -s ejabberd \
      -sasl sasl_error_logger \\{file,\\\"$SASL_LOG_PATH\\\"\\} \
      $ERLANG_OPTS $ARGS \"$@\""
}

to this:

start ()
{
    checknodenameusage
    [ "$?" -eq 0 ] && echo "\nERROR: The node '$ERLANG_NODE' is already running." && return 1

    $EXEC_CMD "$ERL \
      $NAME $ERLANG_NODE \
      -noinput \
      -pa $EJABBERD_EBIN_PATH \
      -mnesia dir \"\\\"$SPOOLDIR\\\"\" \
      $KERNEL_OPTS \
      -s ejabberd \
      -sasl sasl_error_logger \\{file,\\\"$SASL_LOG_PATH\\\"\\} \
      $ERLANG_OPTS $ARGS \"$@\""
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment