Reputation: 155
I am new to erlang and rabbitmq and started going through RabbitMQ codebase. I find that in rabbit.erl start/2 function implemented but seems like start/0 or boot/0 is the function which needs to be called for rabbitMQ start-up. Apologies for a very basic question but really appreciate any help in understanding code flow for RabbitMQ specially for start-up and rabbit-boot-step process.
Thanks in advance.
Upvotes: 3
Views: 375
Reputation: 2313
The RabbitMQ boot process is documented here: https://github.com/videlalvaro/rabbit-internals/blob/master/rabbit_boot_process.md
I'm curious to know why you want to look into that.
Upvotes: 1
Reputation: 4906
The RabbitMQ file you are looking at rabbit.erl
implements the Application behaviour. This means that when the Erlang VM is told to start the rabbit
application it will look for a .app file(RabbitMQ's is in ebin/rabbit_app.in
). On line 16 you can see that the rabbit
is the module responsible for starting the application. Erlang assumes the module implements the application behavior (if it didn't you would definitely run into errors). Once Erlang has everything setup it invokes the start/2
callback in rabbit.erl
. This in turn calls rabbit_sup:start_link/0
. I have never used RabbitMQ before so I am unsure what happens after that but most likely the supervisor starts all the other supervisors and worker processes needed for RabbitMQ to function.
As for start/0
and boot/0
, they are not Erlang callback functions. They are custom functions created by the RabbitMQ engineers. I imagine these functions are used to start the application in specific scenarios (e.g. testing, boot the application in the interpreter during development, etc...).
Hope this helps! Always look for the behaviour
module attribute (-behaviour(application).
) when inspecting an Erlang module. Once you know what behavior a module implements you can look up that behavior (erlang application behavior) and learn a lot more about how things work.
Upvotes: 0