erlangrebaryaws

YAWS Embedded as dependence in rebar3 issue


I'm trying to use YAWS in an application (as dep) in embedded mode. I'm using rebar3. My application gets yaws as dep & builds via rebar3 (after some tweaking) & releases fine, but when I launch it YAWS is crashing out. It appears it is trying to start up even through it should be in embedded mode.

I'm attempting to configured the yaws.app.src into embedded mode env as follows:

{application,yaws,
 [{description,"yaws WWW server"},
  {vsn, {cmd, "sed -ne '1,/^YAWS_VSN=/s/^YAWS_VSN=//p' vsn.mk 2>/dev/null"}},
  {modules,[]},
  {registered, []},
  {mod,{yaws_app,[]}},
  {env, [
           {embedded, true}             % true | false
        ]},
  {applications,[kernel,stdlib@APPDEPS@]}]}.

I think it is starting automatically since it is listed as an application in my app.src file. (Not sure though) If I remove from here I don't get files in release for YAWs. But when launched it is looking for config file and not acting like in embedded mode.

=INFO REPORT==== 2-Sep-2015::19:00:58 ===
Yaws: Using config file /Users/someuser/csvp/_build/default/lib/yaws/etc/yaws/yaws.conf

What am I missing?? Why is it still launching and why it is using the config file?


Solution

  • I suspect that you're specifying that Yaws should start up when the release starts, same as other applications in the release; basically, the equivalent of calling application:start(yaws). What you should be doing instead is loading Yaws but not starting it — the equivalent of application:load(yaws) — which I believe you can do by specifying {yaws, load} in the relx section of your rebar.config file. You should then follow these instructions in the Yaws documentation under the "Starting under your own supervisor" section. Depending on your specific needs, you'd call one of the yaws_api:embedded_start_conf/1,2,3,4 to get the Yaws server confs, global conf, and child specs. You'd then use the child specs to start Yaws under your supervisors, as explained under "Using embedded_start_conf", and then set the Yaws configuration server confs and global conf to get it running.