# pylint: disable=protected-access
import atexit
import os
+import signal
from typing import Any, Optional
from supervisor.compat import as_string
from supervisor.events import ProcessStateFatalEvent, ProcessStateRunningEvent, ProcessStateStartingEvent, subscribe
+from supervisor.options import ServerOptions
from supervisor.process import Subprocess
from supervisor.states import SupervisorStates
from supervisor.supervisord import Supervisor
systemd_notify(READY="1", STATUS="Ready")
+def ServerOptions_get_signal(self):
+ sig = self.signal_receiver.get_signal()
+ if sig == signal.SIGHUP and superd is not None:
+ superd.options.logger.info("received SIGHUP, forwarding to the process 'manager'")
+ manager_pid = superd.process_groups["manager"].processes["manager"].pid
+ os.kill(manager_pid, signal.SIGHUP)
+ return None
+
+ return sig
+
+
def inject(supervisord: Supervisor, **_config: Any) -> Any: # pylint: disable=useless-return
global superd
superd = supervisord
subscribe(ProcessStateStartingEvent, check_for_starting_manager)
subscribe(ProcessStateRunningEvent, check_for_runnning_manager)
+ # forward SIGHUP to manager
+ ServerOptions.get_signal = ServerOptions_get_signal
+
# this method is called by supervisord when loading the plugin,
# it should return XML-RPC object, which we don't care about
# That's why why are returning just None
supervisor.rpcinterface_factory = knot_resolver_manager.kresd_controller.supervisord.plugin.patch_logger:inject
target = {{ config.target }}
-[rpcinterface:manager_lifecycle_monitor]
-supervisor.rpcinterface_factory = knot_resolver_manager.kresd_controller.supervisord.plugin.manager_lifecycle_monitor:inject
+[rpcinterface:manager_integration]
+supervisor.rpcinterface_factory = knot_resolver_manager.kresd_controller.supervisord.plugin.manager_integration:inject
[rpcinterface:sd_notify]
supervisor.rpcinterface_factory = knot_resolver_manager.kresd_controller.supervisord.plugin.sd_notify:inject