Skip to content

Commit

Permalink
[config] Reload Monit configuration after potential hostname changes (#…
Browse files Browse the repository at this point in the history
…1132)

**- What I did**

After hostname changes, we need to reload the Monit configuration in order for Monit to pick up the new system hostname. Otherwise, it will retain the previous hostname.

**- How I did it**

Call `sudo monit reload` after restarting hostname-config.service.
  • Loading branch information
jleveque authored and abdosi committed Oct 13, 2020
1 parent 8a9bfe8 commit 0a08264
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,10 @@ def _restart_services():

execute_systemctl(services_to_restart, SYSTEMCTL_ACTION_RESTART)

# Reload Monit configuration to pick up new hostname in case it changed
click.echo("Reloading Monit configuration ...")
clicommon.run_command("sudo monit reload")


def is_ipaddress(val):
""" Validate if an entry is a valid IP """
Expand Down Expand Up @@ -1031,6 +1035,11 @@ def hostname(new_hostname):
except SystemExit as e:
click.echo("Restarting hostname-config service failed with error {}".format(e))
raise

# Reload Monit configuration to pick up new hostname in case it changed
click.echo("Reloading Monit configuration ...")
clicommon.run_command("sudo monit reload")

click.echo("Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`.")

#
Expand Down

0 comments on commit 0a08264

Please sign in to comment.