mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 10:30:03 -03:30
Merge pull request #1204 from chrismeyersfsu/fix-remove_mongo
remove the starting of mongo
This commit is contained in:
commit
3fde9050a4
@ -54,7 +54,7 @@ from social.backends.utils import load_backends
|
||||
|
||||
# AWX
|
||||
from awx.main.task_engine import TaskSerializer, TASK_FILE, TEMPORARY_TASK_FILE
|
||||
from awx.main.tasks import mongodb_control, send_notifications
|
||||
from awx.main.tasks import send_notifications
|
||||
from awx.main.access import get_user_queryset
|
||||
from awx.main.ha import is_ha_environment
|
||||
from awx.api.authentication import TaskAuthentication, TokenGetAuthentication
|
||||
@ -274,7 +274,6 @@ class ApiV1ConfigView(APIView):
|
||||
|
||||
# Only stop mongod if license removal succeeded
|
||||
if has_error is None:
|
||||
mongodb_control.delay('stop')
|
||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
else:
|
||||
return Response({"error": "Failed to remove license (%s)" % has_error}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
@ -14,7 +14,6 @@ import pipes
|
||||
import re
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
import tempfile
|
||||
import thread
|
||||
import time
|
||||
@ -180,30 +179,6 @@ def notify_task_runner(metadata_dict):
|
||||
queue = FifoQueue('tower_task_manager')
|
||||
queue.push(metadata_dict)
|
||||
|
||||
@task()
|
||||
def mongodb_control(cmd):
|
||||
# Sanity check: Do not send arbitrary commands.
|
||||
if cmd not in ('start', 'stop'):
|
||||
raise ValueError('Only "start" and "stop" are allowed.')
|
||||
|
||||
# Either start or stop mongo, as requested.
|
||||
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() == 0
|
||||
|
||||
# If there was an error, log it.
|
||||
if err:
|
||||
logger.error(err)
|
||||
|
||||
if cmd == 'stop' and shutdown_failed:
|
||||
p = subprocess.Popen('sudo mongod --shutdown -f /etc/mongod.conf', shell=True)
|
||||
p.wait()
|
||||
|
||||
@task(bind=True)
|
||||
def handle_work_success(self, result, task_actual):
|
||||
if task_actual['type'] == 'project_update':
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user