Skip to content

Commit

Permalink
Pause running workflows when stopping beeflow with 'beeflow core stop'
Browse files Browse the repository at this point in the history
  • Loading branch information
pagrubel committed Apr 29, 2024
1 parent 6a14f4a commit 583477c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions beeflow/client/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,16 +440,26 @@ def status():
@app.command()
def stop(query='yes'):
"""Stop the current running beeflow daemon."""
if query == 'yes':
# Check workflow states; warn if there are active states, pause running workflows
workflow_list = bee_client.get_wf_list()
concern_states = {'Running', 'Initializing', 'Waiting'}
concern = {item for row in workflow_list for item in row}.intersection(concern_states)
# For the interactive case
if query == 'yes' and concern:
ans = input("""
** Please ensure all workflows are complete before stopping beeflow. **
** Check the status of workflows by running 'beeflow list'. **
** There are running workflows. **
** Running workflows will be paused. **
Are you sure you want to kill beeflow components? [y/n] """)
else:
ans = 'y'
if ans.lower() != 'y':
return
# Pause running or waiting workflows
workflow_list = bee_client.get_wf_list()
for _name, wf_id, state in workflow_list:
if state in {'Running', 'Waiting'}:
bee_client.pause(wf_id)
resp = cli_connection.send(paths.beeflow_socket(), {'type': 'quit'})
if resp is None:
beeflow_log = paths.log_fname('beeflow')
Expand All @@ -459,7 +469,7 @@ def stop(query='yes'):
sys.exit(1)
# As long as it returned something, we should be good
beeflow_log = paths.log_fname('beeflow')
if query == "no":
if query == "yes":
print(f'Beeflow has stopped. Check the log at "{beeflow_log}".')


Expand Down

0 comments on commit 583477c

Please sign in to comment.