tags:

views:

149

answers:

1

What is the proper way to embed the inets:httpd module inside an existing application?

I would like an example / guidelines to achieving this, please.

Updated: I want to be able to start an inets:httpd service dynamically from within an existing application. I do not want a solution which leverages a boot script as using this method doesn't allow to specify a port dynamically.

A: 

The release tools will allow you to put together a complete standalone release including all dependent applications. If that is what you meant by embed then I would start there. It's used for creating erlang applications meant for embededed systems.

http://www.erlang.org/doc/design%5Fprinciples/release%5Fstructure.html#id2272165 has an overview of this.

Update After seeing your update. Then all you need to do is:

inets:start(); inets:start(httpd, ServiceConfig)

somewhere in your application. Keep in mind that when you do this the service will not be handled by inets application takeover and failover but can be soft-code reloaded. You will be responsible for handling this yourself. If you don't mind losing that functionality then this should work just fine.

Jeremy Wall
@Jeremy: please see my update.
jldupont
@Jeremy: thanks. The problems I were having trying to "embed" inets:httpd stemmed from my overall application structure. Now that I have restructured around a proper OTP "format", my troubles are gone. I'll accept your solution.
jldupont