Re: HOWTO: Detect embedded mode Yaws 1.77 app death and restart
Oscar Hellström <
oscar@...>
2008-08-04 12:55:46 GMT
Hi Edwin,
If you take a look at how OTP handles Included Applications [1] you can
see how an "embedded" application is supposed to be started.
Al least in Yaws 1.68, the top supervisor is called yaws_sup and can be
started with the following child definition in your supervisor:
Yaws = {yaws, {yaws_sup, start_link, []},
permanent, infinity, supervisor, [yaws_sup]}
Before doing this though you should set the environment variable
embedded to true for yaws: application:set_env(yaws, embedded, true).
After it's started, you'll need to feed some configuration, which can be
done with the yaws_api:setconf/2.
Your application callback (for the application including/embedding yaws)
can look like:
application:set_env(yaws, embedded, true),
{ok, Pid} = my_top_sup:start_link(), % This has to have the yaws child
% definition somewhere
Docroot = code:priv_dir(wv_client),
{ok, Port} = PORT_I_WANT_TO_LISTEN_TO,
GConf = #gconf{
trace = false,
logdir = filename:join([code:root_dir(), "log"]),
tmpdir = "/tmp/",
yaws = "ICQ/AIM WAPSMS CIR",
flags =
?GC_COPY_ERRLOG bor
?GC_FAIL_ON_BIND_ERR bor
?GC_PICK_FIRST_VIRTHOST_ON_NOMATCH
},
SConf = #sconf{
port = Port,
docroot = Docroot,
appmods = [{"/path", my_callback_module}],
listen = {0,0,0,0},
servername = "icq_aim" },
yaws_api:setconf(GConf, [[SConf]]),
{ok, Pid}.
[1] -
http://www.erlang.org/doc/design_principles/included_applications.html#8
Edwin Fine wrote:
> I am using Yaws 1.77 in embedded mode in an application. Starting Yaws in
> embedded mode starts Yaws as a separate application. The supervisor
> (yaws_sup) restart strategy changed since Yaws 1.76 (?) to not restart, for
> understandable reasons given in the source code.
>
> Here's the thing: if for example the gserv process dies, then yaws_server
> crashes and the entire yaws application dies. I can't figure out how to
> detect that it died so that I can restart it from within my supervisor,
> because yaws:start_embedded() returns only the atom ok (no pid to link to).
> What do I link to in order to detect the crash, or what other mechanism
> should I use? I just can't figure it out.
>
> E.
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Erlyaws-list mailing list
> Erlyaws-list <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Best regards
--
--
Oscar Hellström, oscar <at> erlang-consulting.com
Office: +44 20 7655 0337
Mobile: +44 798 45 44 773
Erlang Training and Consulting
http://www.erlang-consulting.com/
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list