Added handling of Ctrl-C in interactive mode. Resolves #803.

This commit is contained in:
Griatch 2015-09-07 23:57:50 +02:00
parent f1834dc194
commit 4c6ff5b12d
2 changed files with 11 additions and 2 deletions

View file

@ -16,6 +16,7 @@ import shutil
import importlib
from argparse import ArgumentParser
from subprocess import Popen, check_output, call, CalledProcessError, STDOUT
import twisted
import django
# Signal processing
@ -325,6 +326,11 @@ ERROR_NODJANGO = \
ERROR: Django does not seem to be installed.
"""
NOTE_KEYBOARDINTERRUPT = \
"""
STOP: Caught keyboard interrupt while in interactive mode.
"""
#------------------------------------------------------------
#
# Functions
@ -1039,8 +1045,10 @@ def server_operation(mode, service, interactive, profiler):
try:
process.wait()
except KeyboardInterrupt:
print "\nKeyboard interrupt sent in interactive mode.\n"
server_operation("stop", "portal", False, False)
return
finally:
print NOTE_KEYBOARDINTERRUPT
elif mode == 'reload':
# restarting services

View file

@ -187,6 +187,7 @@ def start_services(server_argv, portal_argv):
try:
message, rc = processes.get()
except KeyboardInterrupt:
# this only matters in interactive mode
break
# restart only if process stopped cleanly