Chicago boss and background processes

188 views
Skip to first unread message

Gerhard Fensch

unread,
Nov 7, 2012, 3:24:59 PM11/7/12
to chica...@googlegroups.com
Hi there,

I'm very new at erlang and chicago boss. I got a simple site running and
want to implement a own logging system, more for curiosity and learning.
Waht I tried: I put a logger module in src/lib, which is startet with
register(logger, spawn(fun loop/0)). The thing is, if I try this on the
shell, I can send the process message after message after message … and so
on. If I try to access the process from a controller, only the first call
are successful, but after that call the process dies. Is chicago boss
killing all processes except it own ones?

Thanks,
Gerhard

Evan Miller

unread,
Jan 17, 2013, 3:48:20 PM1/17/13
to ChicagoBoss
Make sure you use the module:function/N form instead of a local function. Erlang kills processes running old code on code reloads, and processes with references to local functions won't survive.

Evan
 

        Thanks,
        Gerhard

--





--
Evan Miller
http://www.evanmiller.org/

Péter Molnár

unread,
May 15, 2013, 5:11:15 PM5/15/13
to chica...@googlegroups.com
Hi Evan,

I have a similar problem. I am trying to get a background process up and running bu I was unable todoo,ithas alwazs terminated )and in case I  ran a supervisor, the children always crashed.
Let's assume the following, there is a simple loop like this (i use this for testing):

loop_link() ->
    Pid=spawn_link(?MODULE,loop,[]),
     erlang:unlink(Pid),
    {ok, Pid}   
.

loop() ->
    receive
    _ ->
            ?MODULE:loop()
    after 1000 ->
            io:format("a~n"),
            ?MODULE:loop()
    end
.

I have tried with spawn, spawn_link with unlink, everything.The result is the same, here is a log of a sample run (init-dev):
task_supervisor2:loop_link()
(leader@dom0)1> .
{ok,<0.432.0>}
a              
a              
a              
(leader@dom0)2> 23:02:46.724 [info] Loading routes from "/home/mpeter/cc_dev/cb/cc_webui/priv/cc_webui.routes" ....
a
(leader@dom0)2> 23:02:47.268 [info] Loading routes from "/home/mpeter/cc_dev/cb/cc_webui/priv/cc_webui.routes" ....
23:02:47.271 [info] GET / [cc_webui] 200 547ms
23:02:47.284 [error] Error in process <0.437.0> on node 'leader@dom0' with exit value: {{case_clause,closed},[{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,514}]}]}


23:02:47.372 [error] Supervisor ranch_conns_sup had child ranch_conns_sup started with {ranch_conns_sup,start_protocol,undefined} at <0.437.0> exit with reason no case clause matching closed in cowboy_protocol:execute/4 line 514 in context child_terminated
a
(leader@dom0)2> 23:02:47.823 [info] GET / [cc_webui] 200 554ms
a
a              
(leader@dom0)2> 23:02:49.900 [info] Loading routes from "/home/mpeter/cc_dev/cb/cc_webui/priv/cc_webui.routes" ....
23:02:50.403 [info] Loading routes from "/home/mpeter/cc_dev/cb/cc_webui/priv/cc_webui.routes" ....
23:02:50.447 [info] GET / [cc_webui] 200 548ms
23:02:50.448 [error] Error in process <0.453.0> on node 'leader@dom0' with exit value: {{case_clause,closed},[{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,514}]}]}


23:02:50.495 [error] Supervisor ranch_conns_sup had child ranch_conns_sup started with {ranch_conns_sup,start_protocol,undefined} at <0.453.0> exit with reason no case clause matching closed in cowboy_protocol:execute/4 line 514 in context child_terminated
23:02:50.956 [info] GET / [cc_webui] 200 553ms
...

letme explain: it works as long as I click on pages and wait until they are loaded. But once I click fast (without waiting for the previous page to load), it will just kill the process after a couple of clicks.... A supervisor wont really help because I need a lot of backgound processes and their startup is kind of heavy, it is not an option to mas-restart them whenever a user starts to click on links fast..
What is the proper way of handling this? I need a lot of bg processes representing entities that run reliably in the background no matter what happens to the frontend (ok, actually it can crass if boss crashes completely but it should crash on a regular basis).

Thank you for your help in advance!

Best regards,
Peter Molnar




Peter
Reply all
Reply to author
Forward
0 new messages