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

Function salt_proxy

salt/scripts.py:391–458  ·  view source on GitHub ↗

Start a proxy minion.

()

Source from the content-addressed store, hash-verified

389
390
391def salt_proxy():
392 """
393 Start a proxy minion.
394 """
395 _pin_multiprocessing_fork()
396
397 import multiprocessing
398
399 import salt.cli.daemons
400 import salt.utils.platform
401
402 if "" in sys.path:
403 sys.path.remove("")
404
405 if salt.utils.platform.is_windows():
406 proxyminion = salt.cli.daemons.ProxyMinion()
407 proxyminion.start()
408 return
409
410 if "--disable-keepalive" in sys.argv:
411 proxyminion = salt.cli.daemons.ProxyMinion()
412 proxyminion.start()
413 return
414
415 # keep one minion subprocess running
416 supervisor_privileges_dropped = False
417 while True:
418 try:
419 queue = multiprocessing.Queue()
420 except Exception: # pylint: disable=broad-except
421 # This breaks in containers
422 proxyminion = salt.cli.daemons.ProxyMinion()
423 proxyminion.start()
424 return
425 process = multiprocessing.Process(
426 target=proxy_minion_process, args=(queue,), name="ProxyMinion"
427 )
428 process.start()
429 # See the matching note in salt_minion(); the supervisor only
430 # needs root for the first fork's verify_env/pidfile setup, and
431 # leaving it as root afterwards is the bug described in #68115.
432 if not supervisor_privileges_dropped:
433 import salt.config
434
435 _supervisor_drop_privileges(salt.config.proxy_config, "proxy")
436 supervisor_privileges_dropped = True
437 try:
438 process.join()
439 try:
440 restart_delay = queue.get(block=False)
441 except Exception: # pylint: disable=broad-except
442 if process.exitcode == 0:
443 # Minion process ended naturally, Ctrl+C or --version
444 break
445 restart_delay = 60
446 if restart_delay == 0:
447 # Minion process ended naturally, Ctrl+C, --version, etc.
448 sys.exit(process.exitcode)

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected