preloader
心得

Mosquitto MQTT Reload Configuration Without Stop Execution | Mosquitto MQTT broker 重新載入設定檔時無須重啟

Mosquitto MQTT Reload Configuration Without Stop Execution | Mosquitto MQTT broker 重新載入設定檔時無須重啟

I want to update some settings of mosquitto MQTT broker without stop running. There is a way to meet the goal.

 

First, you need to setup pid_file setting of mosquitto.conf. pid_file setting will set pid content such as process identifier in the file under assigned path.

And then I can setup a setting that I want process execution of mosquitto to reload configurations, for example acl_file. After I confirming a setting of a reloadable setting is correct, I will type command in the command line: kill -SIGHUP MOSQUITTO_PID. kill command with -SIGHUP PID will tell mosquitto to reload configuration and its-related settings to execution context.

 

Notice_1: You should change MOSQUITTO_PID as you find identifier in actual content in pid_file file.
Notice_2: It needs to adapt call kill slightly if you use mosquitto with docker. For example,docker exec -it <container> kill -SIGHUP MOSQUITTO_PID or docker container exec <container> -it kill -SIGHUP MOSQUITTO_PID And you must ensure there is a file mounted in pid_file path into the container.

List all of reloadable configuration.

You can find following by search Reloaded on Reload signal

  • acl_file, Warning: The currently loaded ACLs will be freed and reloaded. Existing subscriptions will be affected after the reload.
  • allow_duplicate_messages
  • allow_zero_length_clientid
  • auto_id_prefix
  • autosave_interval
  • autosave_on_changes
  • certfile
  • clientid_prefixes, Notice: currently connected clients will be unaffected by any changes.
  • connection_messages
  • log_dest
  • log_timestamp
  • log_timestamp_format
  • log_type
  • max_inflight_bytes
  • max_inflight_messages
  • max_keepalive
  • max_packet_size
  • max_queued_bytes
  • max_queued_messages
  • memory_limit, Warning: Setting to a lower value and reloading will not result in memory being freed.
  • message_size_limit
  • password_file, Notice: The currently loaded username and password data will be freed and reloaded. Clients that are already connected will not be affected.
  • per_listener_settings
  • persistence
  • persistence_file
  • persistence_location
  • persistent_client_expiration
  • psk_file
  • queue_qos0_messages
  • retain_available
  • set_tcp_nodelay
  • sys_interval
  • upgrade_outgoing_qos

 

Reference link: