mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 15:09:32 -02: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:
@@ -133,14 +133,19 @@ def mongodb_control(cmd):
|
|||||||
p = subprocess.Popen('sudo service mongod %s' % cmd, shell=True,
|
p = subprocess.Popen('sudo service mongod %s' % cmd, shell=True,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
out, err = p.communicate()
|
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 there was an error, log it.
|
||||||
if err:
|
if err:
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
|
|
||||||
if cmd == 'stop':
|
if cmd == 'stop' and shutdown_failed:
|
||||||
time.sleep(30)
|
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()
|
out, err = p.communicate()
|
||||||
logger.info("Shutdown command output: %s;%s" % (out, err))
|
logger.info("Shutdown command output: %s;%s" % (out, err))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user