Oscar, thanks. My mistake was thinking I could do it all with the documented call yaws:start_embedded.

On Mon, Aug 4, 2008 at 4:59 AM, Oscar Hellström <oscar@erlang-consulting.com> wrote:
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),
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
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.



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


Erlyaws-list mailing list

Best regards
Oscar Hellström, oscar@erlang-consulting.com
Office: +44 20 7655 0337
Mobile: +44 798 45 44 773
Erlang Training and Consulting

For every expert there is an equal and opposite expert - Arthur C. Clarke