|
|
@ -94,6 +94,24 @@ def getenv_int(key, default=0):
|
|
|
|
return default
|
|
|
|
return default
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def save_pid(name):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
When debugging and profiling, it is very annoying to poke through the
|
|
|
|
|
|
|
|
process list to discover the currently running Ansible and MuxProcess IDs,
|
|
|
|
|
|
|
|
especially when trying to catch an issue during early startup. So here, if
|
|
|
|
|
|
|
|
a magic environment variable set, stash them in hidden files in the CWD::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
alias muxpid="cat .ansible-mux.pid"
|
|
|
|
|
|
|
|
alias anspid="cat .ansible-controller.pid"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gdb -p $(muxpid)
|
|
|
|
|
|
|
|
perf top -p $(anspid)
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if os.environ.get('MITOGEN_SAVE_PIDS'):
|
|
|
|
|
|
|
|
with open('.ansible-%s.pid' % (name,), 'w') as fp:
|
|
|
|
|
|
|
|
fp.write(str(os.getpid()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MuxProcess(object):
|
|
|
|
class MuxProcess(object):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Implement a subprocess forked from the Ansible top-level, as a safe place
|
|
|
|
Implement a subprocess forked from the Ansible top-level, as a safe place
|
|
|
@ -173,11 +191,13 @@ class MuxProcess(object):
|
|
|
|
if _init_logging:
|
|
|
|
if _init_logging:
|
|
|
|
ansible_mitogen.logging.setup()
|
|
|
|
ansible_mitogen.logging.setup()
|
|
|
|
if cls.child_pid:
|
|
|
|
if cls.child_pid:
|
|
|
|
|
|
|
|
save_pid('controller')
|
|
|
|
ansible_mitogen.affinity.policy.assign_controller()
|
|
|
|
ansible_mitogen.affinity.policy.assign_controller()
|
|
|
|
cls.child_sock.close()
|
|
|
|
cls.child_sock.close()
|
|
|
|
cls.child_sock = None
|
|
|
|
cls.child_sock = None
|
|
|
|
mitogen.core.io_op(cls.worker_sock.recv, 1)
|
|
|
|
mitogen.core.io_op(cls.worker_sock.recv, 1)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
save_pid('mux')
|
|
|
|
ansible_mitogen.affinity.policy.assign_muxprocess()
|
|
|
|
ansible_mitogen.affinity.policy.assign_muxprocess()
|
|
|
|
cls.worker_sock.close()
|
|
|
|
cls.worker_sock.close()
|
|
|
|
cls.worker_sock = None
|
|
|
|
cls.worker_sock = None
|
|
|
|