EMQ source code -- start of EMQ

Posted by Dragoa on Sun, 01 Dec 2019 06:26:35 +0100

It's back to erlang again. It's kind of friendly to go back to erlang after using it for a while. In the project, mqtt is also prepared to be used for message reporting. By the way, I want to see his code.

In erlang, application s are managed by a supervisor. In emq, emqttd sup is the largest supervisor, and there are many supervisors or worker s connected to it.

ekka:start()
emqttd_sup
|-------->emqttd_ctl Responsible for emqttd_ctl Order it rpc handler
|-------->emqttd_hooks(hook Function processing)
|-------->emqttd_router(various node Message routing between)
|-------->emqttd_pubsub_sup(Administration pubsub Dependent supervisor)
|-------->emqttd_pool_sup(emqttd_pubsub Of supervisor)gproc_pool
               |----->emqttd_pubsub_1(worker)
               |----->emqttd_pubsub_2(worker)
|-------->emqttd_pool_sup(emqttd_server Of supervisor)gproc_pool
               |----->emqttd_server_1(worker)
               |----->emqttd_server_2(worker)
|--------->emqttd_stats(stats topic Relevant statistics)
|--------->emqttd_stats(metrics topic Relevant statistics)
|--------->emqttd_pool_sup(pooler I don't see where it's used. It's fast)gproc_pool
             |------->pooler_1(worker)
             |------->pooler_2(worker)
|--------->emqttd_sm_sup( session management supervisor)gproc_pool
             |------->emqttd_sm_1(worker)
             |------->emqttd_sm_2(worker)
|--------->emqttd_ws_client_sup(websocket client supervisor)gproc_pool
             |------->emqttd_ws_client_1(worker)
             |------->emqttd_ws_client_2(worker)
|--------->emqttd_broker(broker Statistical correlation handler)
|--------->emqttd_alarm(system alerm Dependent handler)
|--------->emqttd_mod_sup(External management mod Of supervisor)
|--------->emqttd_bridge_sup_sup(bridge supervisor)
|--------->emqttd_access_control(auth/acl Related management module)
|--------->emqttd_sysmon_sup(system monitor supervisor)
             |-------->emqttd_sysmon(vm system monitor)
register_acl_mod()
start_listener()

After that, I started socket monitoring and waited for the new connection.
The advantage of erlang is that it has a complete process monitoring system. For details, please refer to Here , the supervisor will restart you automatically after the subprocess exits.

Topics: Erlang supervisor Session socket