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.