[erlang-questions] Deploying multiple webapps

Michael Truog mjtruog@REDACTED
Wed Dec 16 22:16:55 CET 2015


On 12/16/2015 12:31 PM, Hugo Mills wrote:
>     Hi, Loïc,
>
> On Wed, Dec 16, 2015 at 01:21:09AM +0100, Loïc Hoguin wrote:
>> I have been working on RabbitMQ these past few months, and one of
>> the tasks I got assigned was to switch the Web components from
>> Webmachine to Cowboy.
>>
>> RabbitMQ already had a way to have different services on different
>> URLs running under the same port, as you describe. So my work was in
>> part to make it work with Cowboy.
>>
>> I didn't have to change much.
>>
>> I made a tiny middleware that queries the RabbitMQ component keeping
>> tracks of all the services, that then returns with the 'dispatch'
>> environment variable added. This middleware runs just before the
>> cowboy_router middleware: https://github.com/rabbitmq/rabbitmq-web-dispatch/blob/rabbitmq-management-63/src/rabbit_cowboy_middleware.erl#L27
>>
>> The process keeping tracks of all services simply has a mapping from
>> /service1/ to the service's dispatch list (/service1/ is added
>> dynamically).
>>
>> This works pretty well, is all on one node, one port, just like you
>> need, and doesn't require much code. I suppose it wouldn't be too
>> difficult to extract and make it its own project, if that's
>> something people need.
>>
>> Note that everything I talk about here has not been merged yet; but
>> I'm getting close to completion (all tests pass, yada yada).
>     It sounds like it would be a big part of a solution of what I'd
> like to do.
>
>     I guess another analogy of what I'm trying to do is that it's very
> like a Java Servlet container: something that I can drop services
> into, where the container handles the main HTTP serving and holds the
> configuration of which services it runs, where I don't have to
> recompile, rebuild or redeploy the container to alter the set of
> services running in it.

CloudI provides a service abstraction for fault-tolerant messaging utilizing
the Erlang VM.  The problem you are describing is part of the quickstart at
http://cloudi.org/#Erlang .

CloudI supports non-Erlang programming languages, providing the same
service abstraction, but you can use it for Erlang-only services
(use the https://github.com/CloudI/cloudi_core/ repository to get only the
  Erlang/Elixir support).  If you need to compare this to RabbitMQ, look at
http://cloudi.org/faq.html#1_Messaging .  An Erlang-only example that
provides a bit more information than the quickstart is at
https://github.com/CloudI/CloudI/tree/develop/examples/hello_world5
if you choose to embed CloudI services into an Erlang OTP application
hierarchy (otherwise you would be using the CloudI configuration file
to have an explicit startup order).





More information about the erlang-questions mailing list