How to modify Yaws appmods application files?

I am trying to manage a Yast appmod. So:
yaws.conf:

<server localhost> port = 8005 listen = 127.0.0.1 docroot = /home/ziel/www/CatsScript/src/ appmods = </, myappmod> </server> 

from http://yaws.hyber.org/appmods.yaws myappmod.erl:

 -module(myappmod2). -author(' klacke@bluetail.com '). -include("/home/ziel/erlang/yaws/include/yaws_api.hrl"). -compile(export_all). box(Str) -> {'div',[{class,"box"}], {pre,[],Str}}. out(A) -> {ehtml, [{p,[], box(io_lib:format("A#arg.appmoddata = ~p~n" "A#arg.appmod_prepath = ~p~n" "A#arg.querydata = ~p~n", [A#arg.appmoddata, A#arg.appmod_prepath, A#arg.querydata]))}]}. 

And it worked when I used it for the first time. But later, when I changed something in myappmod.erl, nothing changed in response from the server. Than I removed myappmod.erl, but it still works. What to do to make some changes?

+6
source share
1 answer

When you start Yaws, it ultimately refers to your myappmod2 module, causing the Erlang runtime to load the beam file created by compiling the module. After downloading it, it remains loaded until you reboot it, for example, through the Erlang interactive shell, or stop and restart Yaws and Erlang runtime. Just recompiling the module from the outside does not restart it.

If you launch Yaws interactively via yaws -i , you can press enter after launch to get the Erlang interactive shell. If you change the appmod module and recompile it, make sure you copy the new beam file over the old one, and then just type l(myappmod2). into the interactive shell, and then press enter to reload the myappmod2 module (and don't forget the period after the closing bracket). This lowercase l is the Erlang shell load command . You can also compile the module directly in the shell using the c(myappmod2). command c(myappmod2). , which will compile and load it (in the absence of compilation errors).

If you have Yaws that does not work interactively, say, like a normal background daemon process, you can reload the modules into it by running the following command:

 yaws --load myappmod2 

You can put several module names after the --load option if you want to load them all at once. If your Yaws instance has a specific identifier, make sure that you also use the corresponding --id parameter to identify it.

If you are interested in reloading the recompiled modules, you can look at something like the reloader.erl module, which monitors the recompiled modules and loads them automatically. I would not recommend it for use in production, but it can be useful for development.

+14
source

Source: https://habr.com/ru/post/919587/


All Articles