MCPcopy
hub / github.com/saltstack/salt / salt_minion

Function salt_minion

salt/scripts.py:205–314  ·  view source on GitHub ↗

Start the salt minion in a subprocess. Auto restart minion on error.

()

Source from the content-addressed store, hash-verified

203
204
205def salt_minion():
206 """
207 Start the salt minion in a subprocess.
208 Auto restart minion on error.
209 """
210 _pin_multiprocessing_fork()
211
212 import signal
213
214 import salt.utils.debug
215 import salt.utils.platform
216 import salt.utils.process
217
218 salt.utils.debug.enable_sigusr1_handler()
219
220 salt.utils.process.notify_systemd()
221
222 import multiprocessing
223
224 import salt.cli.daemons
225
226 # Fix for setuptools generated scripts, so that it will
227 # work with multiprocessing fork emulation.
228 # (see multiprocessing.forking.get_preparation_data())
229 if __name__ != "__main__":
230 sys.modules["__main__"] = sys.modules[__name__]
231
232 if "" in sys.path:
233 sys.path.remove("")
234
235 if salt.utils.platform.is_windows():
236 minion = salt.cli.daemons.Minion()
237 minion.start()
238 return
239
240 if "--disable-keepalive" in sys.argv:
241 minion = salt.cli.daemons.Minion()
242 minion.start()
243 return
244
245 def escalate_signal_to_process(
246 pid, signum, sigframe
247 ): # pylint: disable=unused-argument
248 """
249 Escalate the signal received to the multiprocessing process that
250 is actually running the minion
251 """
252 # escalate signal
253 os.kill(pid, signum)
254
255 # keep one minion subprocess running
256 prev_sigint_handler = signal.getsignal(signal.SIGINT)
257 prev_sigterm_handler = signal.getsignal(signal.SIGTERM)
258 supervisor_privileges_dropped = False
259 while True:
260 try:
261 process = multiprocessing.Process(
262 target=minion_process, name="MinionKeepAlive"

Callers

nothing calls this directly

Calls 8

startMethod · 0.95
ProcessMethod · 0.80
exitMethod · 0.80
removeMethod · 0.45
startMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected