running mochiweb app as a daemon on boot in ubuntu

61 views
Skip to first unread message

pablo

unread,
Nov 12, 2009, 9:07:57 AM11/12/09
to MochiWeb
Hi,

Is there an example for a start script for a mochiweb app to run on
boot on ubuntu?
I'm trying to write a script that will start mochiweb automatically
and enable start, stop, restart, reload, status and debug(for
attaching an erlang shell to the running daemon) commands.

If there is no example, can I use start.sh script as a base or do I
need to to something else?

Thanks

wolfgang amadeus

unread,
Nov 12, 2009, 8:59:50 PM11/12/09
to moch...@googlegroups.com
maybe you can check rabbitmq or ejabberd out,you can find the start script and see how it works

Anton Krasovsky

unread,
Nov 13, 2009, 2:26:30 PM11/13/09
to moch...@googlegroups.com
I'm using http://cr.yp.to/daemontools.html on Debian (daemontools-run
package) , that's not exactly what you're asking for but it worth
checking out.

Anton

Bob Ippolito

unread,
Nov 13, 2009, 2:47:25 PM11/13/09
to moch...@googlegroups.com
That's what we do as well

pablo

unread,
Nov 16, 2009, 12:26:50 AM11/16/09
to MochiWeb
Do you use it instead of init.d script?
Do you use the start.sh script that is generated with this skeleton of
a mochiweb app?
Does it support start/stop/restart/reload/status?

On Nov 13, 9:26 pm, Anton Krasovsky <anton.krasov...@gmail.com> wrote:
> I'm usinghttp://cr.yp.to/daemontools.htmlon Debian (daemontools-run
> package) , that's not exactly what you're asking for but it worth
> checking out.
>
> Anton
>

Anton Krasovsky

unread,
Nov 16, 2009, 8:29:15 AM11/16/09
to moch...@googlegroups.com
Yes, I use it instead of init.d script, the startup script I use is
based on start.sh by mochiweb.

The startup script for daemontools is really simple, all it has to do
is to start your application, it can be just one line like:

exec setuidgid $ACCOUNT /opt/erlang/bin/erl -pa $PWD/ebin
$PWD/deps/*/ebin -boot start_sasl -s $APPNAME -name $NODENAME
-setcookie $COOKIE -noinput 2>&1

To start/stop etc, you'll use appropriate daemontools commands, for example:

Check status:

# svstat /etc/service/pavome
/etc/service/pavome: up (pid 5285) 523597 seconds

Kill existing process and start a new one (equivalent of restart):
# svc -k /etc/service/pavome

See the daemontools documentation for the rest.

As an added benefit of using daemontools, can get logs that are
printed by your application stored on a filesystem and rotated by
daemontools: http://cr.yp.to/daemontools/multilog.html


Regards,
Anton

pablo

unread,
Nov 17, 2009, 7:53:30 AM11/17/09
to MochiWeb
Anton,
Thank you for the detailed explanation.

Someone also recommended that I'll take a look at RabbitMQ which use a
simple script that calls a module which have all the logic.
http://hg.rabbitmq.com/rabbitmq-server/file/default/scripts/rabbitmqctl
http://hg.rabbitmq.com/rabbitmq-server/file/default/src/rabbit_control.erl

Yaws has a folder with init scripts for several platforms which could
be useful to have in mochiweb
http://github.com/klacke/yaws/tree/master/scripts/


On Nov 16, 3:29 pm, Anton Krasovsky <anton.krasov...@gmail.com> wrote:
> Yes, I use it instead of init.d script, the startup script I use is
> based on start.sh by mochiweb.
>
> The startup script for daemontools is really simple, all it has to do
> is to start your application, it can be just one line like:
>
> exec setuidgid $ACCOUNT /opt/erlang/bin/erl -pa $PWD/ebin
> $PWD/deps/*/ebin -boot start_sasl -s $APPNAME -name $NODENAME
> -setcookie $COOKIE -noinput 2>&1
>
> To start/stop etc, you'll use appropriate daemontools commands, for example:
>
> Check status:
>
> # svstat /etc/service/pavome
> /etc/service/pavome: up (pid 5285) 523597 seconds
>
> Kill existing process and start a new one (equivalent of restart):
> # svc -k /etc/service/pavome
>
> See the daemontools documentation for the rest.
>
> As an added benefit of using daemontools, can get logs that are
> printed by your application stored on a filesystem and rotated by
> daemontools:http://cr.yp.to/daemontools/multilog.html
>
> Regards,
> Anton
>
> On Mon, Nov 16, 2009 at 5:26 AM, pablo <pablo.pl...@gmail.com> wrote:
>
> > Do you use it instead of init.d script?
> > Do you use the start.sh script that is generated with this skeleton of
> > a mochiweb app?
> > Does it support start/stop/restart/reload/status?
>
> > On Nov 13, 9:26 pm, Anton Krasovsky <anton.krasov...@gmail.com> wrote:
> >> I'm usinghttp://cr.yp.to/daemontools.htmlonDebian (daemontools-run

Anton Krasovsky

unread,
Nov 17, 2009, 11:01:42 AM11/17/09
to moch...@googlegroups.com
Yep, I saw it on the erlang-questions list :)

Thanks,
Anton
> --
>
> You received this message because you are subscribed to the Google Groups "MochiWeb" group.
> To post to this group, send email to moch...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mochiweb?hl=.
>
>
>
Reply all
Reply to author
Forward
0 new messages