Skip to content

Commit

Permalink
Start es before pillows, and consolidate pillow code
Browse files Browse the repository at this point in the history
  • Loading branch information
pr33thi committed Aug 2, 2018
1 parent 6fe068b commit 9a8c2ae
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/commcare_cloud/commands/ansible/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,24 +300,21 @@ def execute_action(self, action, host_pattern=None, process_pattern=None):
"\nRestart is a stop followed by a start.\n Continue?", strict=False):
return 0 # exit code
if action == 'stop' or action == 'restart':
exit_code = self._act_on_pillows(action=action)
if not exit_code == 0:
print("ERROR while stopping pillows. Exiting.")
sys.exit(1)
self._act_on_pillows(action=action)

This comment has been minimized.

Copy link
@gcapalbo

gcapalbo Aug 2, 2018

just realized one more thing - should the action we pass here always be 'stop' (and should it always be 'start' for the one below)? otherwise when action is 'restart' then it looks like we'd be restarting the pillows twice

This comment has been minimized.

Copy link
@dannyroberts

dannyroberts Aug 2, 2018

Member

Good catch @gcapalbo

This comment has been minimized.

Copy link
@pr33thi

pr33thi Aug 2, 2018

Author Contributor

Good call, 26605f1

self._run_rolling_restart_yml(tags='action_stop')

if action == 'start' or action == 'restart':
exit_code = self._act_on_pillows(action=action)
if not exit_code == 0:
print("ERROR while starting pillows. Exiting.")
sys.exit(1)
self._run_rolling_restart_yml(tags='action_start')
self._act_on_pillows(action=action)

def _act_on_pillows(self, action):
# Used to stop or start pillows
ansible_context = AnsibleContext(None)
service = SERVICES_BY_NAME['pillowtop'](self.environment, ansible_context)
exit_code = service.run(action=action)
return exit_code
if not exit_code == 0:
print("ERROR while trying to {} pillows. Exiting.".format(action))
sys.exit(1)

def _run_rolling_restart_yml(self, tags):
from commcare_cloud.commands.ansible.ansible_playbook import run_ansible_playbook
Expand Down

0 comments on commit 9a8c2ae

Please sign in to comment.