[disco-dev] Installing with daemontools

27 views
Skip to first unread message

David King

unread,
Apr 20, 2010, 6:57:59 PM4/20/10
to disc...@googlegroups.com
I'm trying to install disco to run under daemontools's supervise <http://cr.yp.to/daemontools/supervise.html>. Rather than the traditional unix way of launching and daemonising a process, it wants a foreground process (so that it has the PID and can do things like automatic restarts after crashes). Because of this, I'd like to launch lighttpd and beam separately so that it can monitor them.

Is there a more convenient way to launch lighttpd and beam separately than using disco.py to launch them and copy-pasting the actual env variables/commands they launch into new scripts?

--
You received this message because you are subscribed to the Google Groups "Disco-development" group.
To post to this group, send email to disc...@googlegroups.com.
To unsubscribe from this group, send email to disco-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/disco-dev?hl=en.

Ville Tuulos

unread,
Apr 21, 2010, 4:01:29 AM4/21/10
to disc...@googlegroups.com
On Tue, Apr 20, 2010 at 3:57 PM, David King <dk...@ketralnis.com> wrote:
> I'm trying to install disco to run under daemontools's supervise <http://cr.yp.to/daemontools/supervise.html>. Rather than the traditional unix way of launching and daemonising a process, it wants a foreground process (so that it has the PID and can do things like automatic restarts after crashes). Because of this, I'd like to launch lighttpd and beam separately so that it can monitor them.
>
> Is there a more convenient way to launch lighttpd and beam separately than using disco.py to launch them and copy-pasting the actual env variables/commands they launch into new scripts?

"disco master nodaemon" starts master in the erlang shell without
daemonizing it. I'm not sure how well the interactive shell works with
daemontools but it might be ok. Lighttpd can be started in foreground
with the -D flag.

This old bash script for starting master might be also helpful

http://github.com/tuulos/disco/blob/0.2.2/master/disco-master

(removing -detach from erl should help)

The next Disco release (0.3) which will be out in May includes a
built-in web server, removing the need to manage Lighttpd separately.

I have been using daemontools by myself in some past projects. I like
D.J.B's sense of aesthetics. I am sure there would be others as well
who could benefit from Disco supervised by daemontools. Please
consider making your scripts public (:


Ville

David King

unread,
Apr 21, 2010, 1:35:11 PM4/21/10
to disc...@googlegroups.com
> "disco master nodaemon" starts master in the erlang shell without daemonizing it.

Yeah, unfortunately it attaches `supervise' to the Python process rather than the beam one, and I've had trouble in the past where Erlang crashes in some weird way and won't launch again(which is why I'm using supervise in the first place), but the containing process (Python) keeps on running, so supervise can't intervene and isn't really supervising anything. But anyway, a workaround will be fine for my testing phase, which brings me to my next point:

> I'm not sure how well the interactive shell works with daemontools but it might be ok.

Sadly, this doesn't appear to be true :-/ If I launch it interactively it works fine, but when launched from supervise, it crashes like this:

Eshell V5.7.5 (abort with ^G)
(disco_4444_master@mrhost)1> *** Terminating erlang (disco_4444_master@mrhost)
Eshell V5.7.5 (abort with ^G)
(disco_4444_master@mrhost)1> *** Terminating erlang (disco_4444_master@mrhost)
Eshell V5.7.5 (abort with ^G)
(disco_4444_master@mrhost)1> *** Terminating erlang (disco_4444_master@mrhost)

(of course the repeats are because after it crashes, `supervise' restarts it). supervise is calling this run-script:

#!/bin/sh
export HOME=/home/mruser
cd $HOME/disco
exec 2>&1
exec setuidgid mruser bin/disco master nodaemon

So nothing especially fancy is happening. It works interactively, and I'm not setting any environment variables or anything in the interactive shell, so they should behave pretty identically. It's especially strange that erlang starts and then is terminated, rather than just not working at all.

Also, sometimes (maybe 1/50 times) it isn't terminated immediately, sometimes it has time for SASL to spit out some messages.

Eshell V5.7.5 (abort with ^G)
(disco_4444_master@mrhost)1> *** Terminating erlang (disco_4444_master@mrhost)
Eshell V5.7.5 (abort with ^G)
=INFO REPORT==== 20-Apr-2010::17:02:27 ===
{"DISCO BOOTS"}
=INFO REPORT==== 20-Apr-2010::17:02:27 ===
{"Event server starts"}
=INFO REPORT==== 20-Apr-2010::17:02:27 ===
{"DISCO SERVER STARTS"}
=INFO REPORT==== 20-Apr-2010::17:02:27 ===
{"Fair scheduler starts"}
=INFO REPORT==== 20-Apr-2010::17:02:27 ===
{"Scheduler uses fair policy"}
=INFO REPORT==== 20-Apr-2010::17:02:27 ===
{"Fair scheduler: Fair policy"}
=INFO REPORT==== 20-Apr-2010::17:02:27 ===
{"Config table update"}
=INFO REPORT==== 20-Apr-2010::17:02:27 ===
{"OOB server starts"}
=INFO REPORT==== 20-Apr-2010::17:02:27 ===
{'SCGI SERVER STARTS'}
(disco_4444_master@mrhost)1> *** Terminating erlang (disco_4444_master@mrhost)
Eshell V5.7.5 (abort with ^G)
(disco_4444_master@mrhost)1> *** Terminating erlang (disco_4444_master@mrhost)

Other than the returning to its death-loop, this looks identical to when it starts successfully when I run it interactively. If I refresh fast enough, lighttpd will even get a request or two off before being killed again.

Anyone seen this before? I have other Erlang processes running just fine from supervise

David King

unread,
Apr 28, 2010, 5:40:50 PM4/28/10
to disc...@googlegroups.com
> http://github.com/tuulos/disco/blob/0.2.2/master/disco-master
> (removing -detach from erl should help)

This looks to have worked after some hacking and slashing. Included below for intrepid googlers:

#!/bin/bash

# Basic settings

DISCO_SCGI_PORT=${DISCO_SCGI_PORT:-"4444"}
DISCO_ROOT=${DISCO_ROOT:-"/home/reddit/disco/root/"}
DISCO_HOME=${DISCO_HOME:-"/home/reddit/disco/"}
DISCO_LOG=${DISCO_LOG:-"/home/reddit/disco/log/"}
DISCO_ULIMIT=${DISCO_ULIMIT:-"16000000"}
DISCO_PID_DIR=${DISCO_PID_DIR:-"/var/tmp/"}
DISCO_MASTER_HOST=${DISCO_MASTER_HOST:-""}
DISCO_SLAVES_OS=${DISCO_SLAVES_OS:-"linux"}

# Derived settings

DISCO_NAME=${DISCO_NAME:-"disco_$DISCO_SCGI_PORT"}
DISCO_DATA=${DISCO_DATA:-"$DISCO_ROOT/data"}
DISCO_MASTER=${DISCO_MASTER:-"$DISCO_DATA/_$DISCO_NAME"}
DISCO_CONFIG=${DISCO_CONFIG:-"$DISCO_ROOT/$DISCO_NAME.config"}
DISCO_MASTER_LOG=${DISCO_MASTER_LOG:-"$DISCO_LOG/$DISCO_NAME.log"}

if [ ! -e $DISCO_MASTER ] && ! mkdir -p $DISCO_MASTER; then
echo "$DISCO_MASTER doesn't exist"
exit 1
fi
echo "Using master... $DISCO_MASTER"
echo "Using slaves with... $DISCO_SLAVES_OS"
[ -z $DISCO_MASTER_HOST ] || echo "Using master host... $DISCO_MASTER_HOST"

if [ ! -e $DISCO_CONFIG ] && ! echo "[]" > $DISCO_CONFIG; then
echo "Couldn't initialize $DISCO_CONFIG"
exit 1
fi
echo "Using config... $DISCO_CONFIG"

# If DISCO_HEART is not specified, HEART_COMMAND is empty and heart
# will die togehter with the master process.
export HEART_COMMAND=${DISCO_HEART:+"$0 $@"}

# Prevent disasterous memory leaks from trashing the server
ulimit -v $DISCO_ULIMIT 2>/dev/null

erl +K true\
-sname $DISCO_NAME"_master"\
-rsh ssh\
-connect_all false\
-pa "$DISCO_HOME/ebin"\
-kernel error_logger "{file, \"$DISCO_MASTER_LOG\"}"\
-eval "application:start(disco)"

David King

unread,
Apr 28, 2010, 5:44:33 PM4/28/10
to disc...@googlegroups.com
Sorry, that should have -noinput in the arguments to erl, since that's what was causing the "terminated" in the first place. Hopefully the aforementioned intrepid googlers see this one too :)

Ruslan Spivak

unread,
Apr 29, 2010, 9:47:00 AM4/29/10
to disc...@googlegroups.com
David King <dk...@ketralnis.com> writes:

> Sorry, that should have -noinput in the arguments to erl, since that's
> what was causing the "terminated" in the first place. Hopefully the
> aforementioned intrepid googlers see this one too :)

Hi David,

I haven't tried it myself yet, but thanks for sharing this information.

Cheers,
Ruslan
--
An eye for an eye leaves everyone blind.
-Mohandas Karamchand Gandhi (1869-1948)
Reply all
Reply to author
Forward
0 new messages