otp - How do I use Nitrogen as a GUI frontend for an Erlang app? -


i have got basic server-side erlang app (not otp'd yet) start on command-line. want turn interactive system using browser gui nitrogen (version 2.0.4). general plan to

  • turn current module gen_server model part; analyses data , generates events reflect properties of data interested in.
  • add controller module both gen_event (to pick events generated model) , gen_server (to allow queries gui frontend)
  • use nitrogen view, updating relevant pages ajax facilities through calls controller module (which in turn queries model)

as far can see want general application supervisor 3 children: model, view, , controller. talk each other via apis mapped otp communication modes.

and stuck: should put of nitrogen directory tree? should set new app dir structure , have 3 components (including nitrogen) under there? need start nitrogen server child of app supervisor (the nitrogen start script looks rather more complex expected)? have started going through erlang , otp in action, haven't quite finished yet. , need demo system day after tomorrow ;)

what want type "start.sh" on command-line, , use browser connect app via nitrogen.

because of way nitrogen app built, should not build application tightly coupled it. rather, build application, provide apis nitrogen (apis call nitrogen events e.t.c).

then package app otp filesystem, put apps folder of nitrogen. when nitrogen makes or starts add ebin paths of apps long in apps directory.

for example: model , controller implemented within application. in application expose function calls in module (which gen_server behaving) call right nitrogen page. beauty these in same code path.

what do: @ nitrogen quickstart.sh script, @ point starts erlang vm.

 echo "starting nitrogen on inets (http://localhost:8000)..." erl \     -name your_node_name_here \     -pa ./ebin ../apps/*/ebin ../apps/*/include \     -env erl_fullsweep_after 10 \     -eval "application:start(nprocreg)" \     -eval "application:start(quickstart)" \     -eval "application:start(your_application)" 

if application not otp like, create folder called "ebin" in put beam files have.the create folder called: "my_app-1.0" , paste ebin folder in folder

   nitrogen--|--/apps --|--/my_app-1.0 --|--/ebin             |--/doc             |--/rel             |--/support             |--/quickstart 

the full path beam files should

"$nitrogen/apps/my_app-1.0/ebin"
. whenever nitrogen starts add code path beam files. then, if in code have function starts stuff say: main_server:start(). change quickstart.sh found in $nitrogen/quickstart/quickstart.sh appear way.

 echo "starting nitrogen on inets (http://localhost:8000)..." erl \     -name your_node_name_here \     -pa ./ebin ../apps/*/ebin ../apps/*/include \     -setcookie your_funny_cookie_here \     -mnesia dir '"path/to/mnesia/directory"' \     -env erl_fullsweep_after 10 \     -eval "application:start(nprocreg)" \     -eval "application:start(quickstart)" \     -eval "main_server:start()" 

the advantage of if happen change view erlyweb, erlang web, not need make changes model or controller rather exposed apis can called view type library.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -