[erlang-questions] supervised inets httpd process
Ingela Andin
ingela@REDACTED
Mon Jun 28 09:33:00 CEST 2010
Hi!
2010/6/27 Ryan Zezeski <rzezeski@REDACTED>:
> Hi everyone. I'm a newcomer to Erlang and have been reading through
> Programming Erlang for the past week. There is an application I want to
> build to replace a legacy webapp in my workplace. I will be replacing the
> bulk of this application with CouchDB/Erlang but I need a light web
> interface that wraps it to provide service to the legacy endpoints (URLs).
>
> As a first cut, I plan on using the inets application with a custom httpd
> callback module to service the API. I was curious, what is the best way to
> "embed" the httpd server in my application? That is, I'm building an OTP
> compliant application, and I want the httpd server to sit under my
> supervisor.
>
> My first attempt was to create a gen_server callback that called
> inets:start/1 and httpd:start/2 in the init/1 function, but I'm not sure
Note that httpd:start/2 is not a documented function in the latest version
of inets.
> this was the appropriate approach. My second approach was to start inets in
> the supervisor callback init/1, and then pass the httpd startup to the
> supervisor config like so: {inets, start, [httpd,[{port,7777}, ...}.
By default the httpd processes is supervised by the inets applications
supervisor.
The "normal" way would be to make your application a user of the inets
application and let it take care of
the supervison for you.
If you for some reanson want to make your own application the top
supervisor of the httpd service you
shold start it with the option stand_alone e.i.
inets:start(httpd, ServiceConfig, stand_alone).
This will in a sense make the calling process the top supervisor of
the httpd service, and if this process
is a OTP-supervisor it should work as expected.
[...]
Regards Ingela Erlang/OTP team, Ericsson AB
More information about the erlang-questions
mailing list