[rabbitmq-discuss] Strange RabbitMQ management plugin error!
Ciprian Dorin Craciun
ciprian.craciun at gmail.com
Wed Jan 12 17:21:43 GMT 2011
On Wed, Jan 12, 2011 at 17:21, Simon MacMullen <simon at rabbitmq.com> wrote:
> On 11/01/11 18:48, Ciprian Dorin Craciun wrote:
>>
>> I don't see any errors displayed from the management plugin. It
>> just says that it started the web server, serving the usual URL.
>> I've also tried to set both the `force_fine_statistics` and
>> `collect_statistics` but they don't seem to have any effect.
>
> I had a play with your run_rabbit script and I found the problem.
Thank you for your time and effort!
> RabbitMQ has the concept of a boot step - part of the startup process of the
> rabbit application. These are the things like
>
> "starting xyz ...done"
>
> that appear on stdout during startup.
I've seen these boot steps -- both in `rabbit.erl` and in
`rabbit.script`, and I've tried to mirror them (this is how I've got
the `application:run(...)` order), but -- as I'm not that accustomed
with the OTP environment -- I thought that I don't need to explicitly
load the application before starting any of them... So it seems that
this was a very bad assumption. :)
> Some plugins, including rabbit_management_agent need to insert boot steps
> into the rabbit app (as well as being their own apps).
> rabbit_management_agent does this in order to collect the statistics it's
> asked for.
>
> The way this works is that when rabbit starts up it looks for boot steps in
> all *loaded* applications. Our boot script loads all applications, then
> starts them. So you need to as well:
Aha. Got it now.
> ~~~~
> -module (run_rabbit).
>
> -export ([run/0]).
>
> run () ->
> Apps1 = [sasl, os_mon, mnesia, inets, crypto, mochiweb,
> rabbit_mochiweb],
> Apps2 = [rabbit, amqp_client, rabbit_management_agent, webmachine,
> rabbit_management],
>
> [ok = application:load(A) || A <- Apps1 ++ Apps2],
>
> [ok = application:start(A, permanent) || A <- Apps1],
> ok = rabbit:prepare(),
> [ok = application:start(A, permanent) || A <- Apps2],
>
> ok = timer:sleep(120 * 1000),
> ok = init:stop(),
> ok.
> ~~~~
Works perfectly. :)
>>> Also, why have you done this? What problem is it solving?
>>>
>>> Cheers, Simon
>>
>> Good question. :) We'll I'm trying to "embed" RabbitMQ into
>> another Erlang application -- a web server that instead of handling
>> the requests it just puts them on a queue, and waits for the response
>> (the same pattern as in the rpc module is doing). I intend to use
>> `amqp_client` in with the `direct` connector. I've seen that there is
>> a similar project but for SMTP -- `rabbitmq-smtp`.
>
> I think rabbitmq-smtp is just a regular plugin. You might want to consider
> doing the same thing - turning things inside out so that your web server is
> running as a RabbitMQ plugin. This is more or less exactly what the
> management plugin does.
Yes, I've though about this possibility of writing an RabbitMQ
plugin. In fact from my development point of view not much should
change, except maybe only the way I bootstrap the whole application.
But when I decided to "embed" RabbitMQ into my web server (which
is actually one of either Misultin, Mochiweb or inets, I've not
decided yet), I planed that in the end, the web server shall use a
dedicated RabbitMQ instance, but for testing and quick deployment
purposes, I've decided to also (optionally) provide an embed RabbitMQ
instance.
> Or you can continue on your current path, but the extent to which we don't
> support running RabbitMQ this way is quite high :)
>
> Cheers, Simon
I'm perfectly aware that the way I'm doing things right now,
incurs the risk of not being able to one day upgrade to a later
RabbitMQ which breaks this startup style. But embedding RabbitMQ is
too tenting right now. :)
So once again thank you for taking time to help me!
Ciprian.
P.S.: I promise I'll return the favor by releasing the code of the
HTTP gateway -- maybe also as a RabbitMQ plugin. (It's part of an
European funded research project ( www.mosaic-cloud.eu ), and RabbitMQ
has a central role in the whole thing. :) )
More information about the rabbitmq-discuss
mailing list