ostinelli / misultin

Misultin (pronounced mee-sool-téen) is an Erlang library for building fast lightweight HTTP(S) servers, which also supports websockets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to run misultin in detached mode?

subhasri opened this issue · comments

hi,

I am trying to run misultin application in detached mode for my erlang project to handle http requests..
eg: misultin:start_link(Options).
Options consists of port,name,loop function as follows .
[{Port,port number},{name,list_to_atom("misultin_"++integer_to_list(Port))},{loop,Function}].

How to run this in detached mode?

Hi,

I am also facing some issue in running Misultin app in daemon ( -detached mode ).

The application's handle_http is not listing in the specified port, when i tried to run it in -detached mode.

Is there any solution for this.

Thanks.

this is not a misultin-related issue.

misultin is a supervisor, so you have to include it into an application.

more info here:
http://pdincau.wordpress.com/2011/08/22/you-should-not-start-your-supervisors-like-this/

in the examples folder you may find an app skeleton:
https://github.com/ostinelli/misultin/tree/master/examples/application

r.

Hi,

Thanks for your reply..
done as you told.. but still getting same problem.

when i run myapplication in erl shell as follows
#erl

application:start(my_app).
ok
myapp_server:start_misultin(7100,5).
ok

then misultin listening http_requests on ports 7100 to 7104.

but i need to run my application in detached mode(daemon)..
To perform this i wrote one program(here my_program) which open one erlang shell in detached mode
and run my application in that node. I didnt get any error..
but misultin not listening on particular ports to handle requests.

what went wrong?

what may be the problem in handing http_request when i am running my application in detached mode?

my_program is

my_program()->

[|[HostName|]] = string:tokens(atom_to_list(node()),"@"),
Name = "adserver_" ++ integer_to_list(StartPort),
NodeName = list_to_atom(Name ++ "@" ++ HostName),
os:cmd("erl -noshell -env ERL_FULLSWEEP_AFTER 7 -sname " ++ Name ++ " -setcookie abc -detached"),

case catch(rpc:call(NodeName,application, start,[my_app])) of
{'EXIT',} ->
io:format("Exit error ~n"),
"";
{badrpc,
} ->
io:format("badrpc error ~n"),

            "";
    {error,Error}->
io:format("error ~p~n",[Error]),

            "";
    ok->
      case catch( rpc:call(NodeName, myapp_server, start_misultin,[StartPort,NoOfPorts]))of 
       ok ->

        io:format(" myapp_server:misultin successfully started on node ~p~n",[NodeName]);
       E ->
        io:format("myapp_server:misultin not started on node with error ~p~n",[E])
    end.

and my start_misultin process performs following
--------------

start_misultin()->
Ports=lists:seq(Sp,Sp+Nop-1),
lists:foreach(fun(Port)-> misultin:start_link([{port, Port}, {name, list_to_atom("misultin_"++integer_to_list(Port))}, {loop, fun(Req) -> handle_http(Req) end}]) end ,Ports).

Note: misultin is in my erlang library..my application file .app also includes all related misultin files..