3
votes

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.

2
Can you provide a URL to the source code you are looking at? I think I understand what you are asking but some code would help solidify things in my mind.Stratus3D

2 Answers

1
votes

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.

0
votes

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.