diff --git a/config/main.py b/config/main.py index 4f3aeb6bb3..36c13348e2 100755 --- a/config/main.py +++ b/config/main.py @@ -750,6 +750,10 @@ def _restart_services(config_db): 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 interface_is_in_vlan(vlan_member_table, interface_name): """ Check if an interface is in a vlan """ @@ -1233,6 +1237,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`.") # diff --git a/tests/config_test.py b/tests/config_test.py index 023f41337a..4fc6b87626 100644 --- a/tests/config_test.py +++ b/tests/config_test.py @@ -43,6 +43,7 @@ Executing restart of service hostcfgd... Executing restart of service nat... Executing restart of service telemetry... +Reloading Monit configuration ... Please note setting loaded from minigraph will be lost after system reboot. To preserve setting, run `config save`. """