简体   繁体   中英

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?

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.

The whole process of embedding a yaws application is quite poorly documented in my opinion (I intend to put together a guide and blog it myself now) - at some point I was confused and thought application:start(yaws) was a required call in order to successfully embed yaws, so I had placed it in my highest level supervisor code. I must have forgot to remove it, and then I spent ages trying to debug the following weird errors (Yaws was actually working still, but they're scary looking errors). The suggested fix here worked for me as well, remove application:start(yaws) from your code.

=ERROR REPORT==== 28-Dec-2015::08:10:55 ===
Failed to load setuid_drv (from "/usr/home/ec2-user/myapp/_build/default/lib/yaws/priv/lib") : "Cannot open \"/usr/home/ec2-user/myapp/_build/default/lib/yaws/priv/lib/setuid_drv.so\""
=ERROR REPORT==== 28-Dec-2015::08:10:55 ===
FATAL {'EXIT',normal}

=INFO REPORT==== 28-Dec-2015::08:10:55 ===
    application: yaws
    exited: {{shutdown,
                 {failed_to_start_child,yaws_server,
                     {badconf,
                         [{yaws_server,init,1,
                              [{file,
                                   "/usr/home/ec2-user/myapp/_build/default/lib/yaws/src/yaws_server.erl"},
                               {line,190}]},
                          {gen_server,init_it,6,
                              [{file,"gen_server.erl"},{line,328}]},
                          {proc_lib,init_p_do_apply,3,
                              [{file,"proc_lib.erl"},{line,240}]}]}}},
             {yaws_app,start,[normal,[]]}}
    type: temporary
ok

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM