diff --git a/devservices/utils/supervisor.py b/devservices/utils/supervisor.py index 5e2a0317..a831c61c 100644 --- a/devservices/utils/supervisor.py +++ b/devservices/utils/supervisor.py @@ -184,13 +184,21 @@ def start_supervisor_daemon(self) -> None: try: client = self._get_rpc_client() client.supervisor.getState() - # Supervisor is already running, restart it since config may have changed - client.supervisor.restart() + # Supervisor is already running, run supervisord update to update config and restart running processes + # Notes: + # - xmlrpc.client.reloadConfig does not work well here as config changes don't appear to be reloaded, so we use `supervisorctl update` instead + # - processes that are edited/added will not be automatically started + subprocess.run( + ["supervisorctl", "-c", self.config_file_path, "update"], + check=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) - # Wait for supervisor to be ready after restart + # Wait for supervisor to be ready after config reload self._wait_for_supervisor_ready() return - except xmlrpc.client.Fault as e: + except (xmlrpc.client.Fault, subprocess.CalledProcessError) as e: capture_exception(e, level="info") pass except (SupervisorConnectionError, socket.error, ConnectionRefusedError): diff --git a/tests/utils/test_supervisor.py b/tests/utils/test_supervisor.py index e0e3e055..8ac8502c 100644 --- a/tests/utils/test_supervisor.py +++ b/tests/utils/test_supervisor.py @@ -195,8 +195,13 @@ def test_start_supervisor_daemon_already_running( } supervisor_manager.start_supervisor_daemon() assert mock_rpc_client.return_value.supervisor.getState.call_count == 2 - assert mock_rpc_client.return_value.supervisor.restart.call_count == 1 - assert mock_subprocess_run.call_count == 0 + mock_subprocess_run.assert_called_with( + ["supervisorctl", "-c", supervisor_manager.config_file_path, "update"], + check=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + mock_subprocess_run.assert_called_once() @mock.patch("devservices.utils.supervisor.subprocess.run")