Include the jid (when available) in SystemExit message on Ctrl-c

This commit is contained in:
Erik Johnson 2016-10-03 18:17:08 -05:00
parent 9c9f1f620b
commit 9025be48c5

View file

@ -46,9 +46,24 @@ def _handle_signals(client, signum, sigframe):
hardcrash = client.options.hard_crash
except (AttributeError, KeyError):
hardcrash = False
exit_msg = '\nExiting gracefully on Ctrl-c'
try:
jid = client.local_client.pub_data['jid']
exit_msg += (
'\n'
'This job\'s jid is: {0}\n'
'The minions may not have all finished running and any remaining '
'minions will return upon completion. To look up the return data '
'for this job later, run the following command:\n\n'
'salt-run jobs.lookup_jid {0}'.format(jid)
)
except (AttributeError, KeyError):
pass
_handle_interrupt(
SystemExit('\nExiting gracefully on Ctrl-c'),
Exception('\nExiting with hard crash Ctrl-c'),
SystemExit(exit_msg),
Exception('\nExiting with hard crash on Ctrl-c'),
hardcrash, trace=trace)