[rabbitmq-discuss] rabbitmq-mochiweb

Paul Jones pauljones23 at gmail.com
Sat Apr 17 23:46:21 BST 2010

Hi Benjamin,

In the production mode, mochiweb doesn't really have a docroot setup.
/rabbitmq_lib will serve the files in priv/www, but that is as far as it

However... if you want to serve some other files then you could always use
code similar to what the test mode does to make it happen. For example, if
you were to add:

Handler = rabbit_mochiweb:static_context_handler("", ?MODULE,
ok = rabbit_mochiweb:register_global_handler(Handler),

after the line:
rabbit_mochiweb:register_static_context(ContextRoot, ?MODULE, "priv/www")

in src/rabbit_jsonrpc_channel_app.erl, then once you've installed the plugin
into Rabbit, any file put into
priv/plugins/rabbitmq-jsonrpc-channel/priv/mydocroot should be served from
the root context of mochiweb.

BTW, I've just noticed a bug in the packaging of the jsonrpc-channel plugin
such that if you do run that plugin by installing it via a .ez, you'll need
to copy the priv/www directory into
priv/plugins/rabbitmq-jsonrpc-channel/priv/www (otherwise libraries such as
rabbitmq.js won't be available).


On Sat, Apr 17, 2010 at 11:29 PM, Benjamin Polidore <polidore at gmail.com>wrote:

> Hey, paul, I installed all the dependencies to rabbitmq-jsonrpc-channel
> (see below).
> I see that you add a little context in test mode.  Basically, I was hoping
> to use the plugin to host my HTML and javascript in dev mode so I don't have
> to run another webserver on my laptop.  I prefer to run rabbitmq in
> "production" mode on my laptop, and I was curious what mochiweb thinks the
> docroot is in this mode.
> [{running_applications,
>      [{rabbit_jsonrpc_channel,"RabbitMQ JSON-RPC Channels","0.01"},
>       {rabbit,"RabbitMQ","1.7.2"},
>       {os_mon,"CPO  CXC 138 46","2.2.5"},
>       {sasl,"SASL  CXC 138 11","2.1.9"},
>       {rabbit_jsonrpc,"Rabbit JSON-RPC","0.01"},
>       {rfc4627_jsonrpc,"JSON RPC Service","0.01"},
>       {rabbit_mochiweb,"RabbitMQ Mochiweb Embedding","0.01"},
>       {mochiweb,"MochiMedia Web Server","0.01"},
>       {mnesia,"MNESIA  CXC 138 12","4.4.13"},
>       {stdlib,"ERTS  CXC 138 10","1.16.5"},
>       {kernel,"ERTS  CXC 138 10","2.13.5"}]},
>  {nodes,[rabbit at H5Pro]},
>  {running_nodes,[rabbit at H5Pro]}]
> ...done.
> On Sat, Apr 17, 2010 at 4:11 PM, Paul Jones <pauljones23 at gmail.com> wrote:
>> Hi Benjamin,
>> Which plugins have you installed into RabbitMQ? The mochiweb plugin alone
>> simply embeds a webserver - you'll need to install rabbitmq-jsonrpc and
>> rabbitmq-jsonrpc-channel to get the JSON services.
>> If you have done this, then you might be hitting the fact that when
>> running under test, an additional context is installed under the root that
>> provides all the various test examples. We don't activate this in the
>> "production" mode, since we don't expect you'll want them in a real
>> deployment. The scripts for doing JSON-RPC are still there though - under
>> /rabbitmq_lib (the scripts that are made available via this can be found on
>> the filesystem in priv/www).
>> I hope this answers your question.
>> Cheers,
>> Paul
>> On Sat, Apr 17, 2010 at 8:28 PM, Benjamin Polidore <polidore at gmail.com>wrote:
>>> hi, i'm trying to use the json-channel plugin, and it runs ok when i do
>>> make test, but it doesn't seem to work when i try to start up my broker.
>>>   the port is open, but everything returns 404.  what is mochiweb using
>>> as a docroot when I run it outside make test?  sorry if this is obvious, but
>>> i've been struggling with it for a couple hours.
>>> thanks,
>>> bp
>>> _______________________________________________
>>> rabbitmq-discuss mailing list
>>> rabbitmq-discuss at lists.rabbitmq.com
>>> http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20100417/d0f3a2ab/attachment.htm 

More information about the rabbitmq-discuss mailing list