PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
Dir : /proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/client/ |
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 IP: 209.182.202.254 |
Dir : //proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/client/netapi.py |
""" The main entry point for salt-api """ import logging import signal import salt.loader import salt.utils.process log = logging.getLogger(__name__) class RunNetapi(salt.utils.process.SignalHandlingProcess): """ Runner class that's pickable for netapi modules """ def __init__(self, opts, fname, **kwargs): super().__init__(**kwargs) self.opts = opts self.fname = fname def run(self): netapi = salt.loader.netapi(self.opts) netapi_func = netapi[self.fname] netapi_func() class NetapiClient: """ Start each netapi module that is configured to run """ def __init__(self, opts): self.opts = opts self.process_manager = salt.utils.process.ProcessManager( name="NetAPIProcessManager" ) self.netapi = salt.loader.netapi(self.opts) def run(self): """ Load and start all available api modules """ if not self.netapi: log.error("Did not find any netapi configurations, nothing to start") for fun in self.netapi: if fun.endswith(".start"): name = f"RunNetapi({self.netapi[fun].__module__})" log.info("Starting %s", name) self.process_manager.add_process( RunNetapi, args=(self.opts, fun), name=name ) # Install the SIGINT/SIGTERM handlers if not done so far if signal.getsignal(signal.SIGINT) is signal.SIG_DFL: # No custom signal handling was added, install our own signal.signal(signal.SIGINT, self._handle_signals) if signal.getsignal(signal.SIGTERM) is signal.SIG_DFL: # No custom signal handling was added, install our own signal.signal(signal.SIGTERM, self._handle_signals) self.process_manager.run() def _handle_signals(self, signum, sigframe): # escalate the signals to the process manager self.process_manager._handle_signals(signum, sigframe)