mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 19:30:39 -03:30
Fixes to conditionally invoking mongo shutdown
* Make sure we are waiting on the service script * Improve sudo configuration * Check pidof before attempting to invoke a hard mongo shutdown
This commit is contained in:
parent
10f5308bd8
commit
9b03d22d75
@ -133,14 +133,19 @@ def mongodb_control(cmd):
|
||||
p = subprocess.Popen('sudo service mongod %s' % cmd, shell=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
out, err = p.communicate()
|
||||
p.wait()
|
||||
|
||||
# Check to make sure the stop actually succeeded
|
||||
p = subprocess.Popen('pidof mongod', shell=True)
|
||||
shutdown_failed = p.wait() == 1
|
||||
|
||||
# If there was an error, log it.
|
||||
if err:
|
||||
logger.error(err)
|
||||
|
||||
if cmd == 'stop':
|
||||
if cmd == 'stop' and shutdown_failed:
|
||||
time.sleep(30)
|
||||
p = subprocess.Popen('sudo mongod --shutdown -f /etc/mongod.conf')
|
||||
p = subprocess.Popen('sudo mongod --shutdown -f /etc/mongod.conf', shell=True)
|
||||
out, err = p.communicate()
|
||||
logger.info("Shutdown command output: %s;%s" % (out, err))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user