forked from github/pelican
Exit web server gracefully when user taps CTRL-C
Users were previously met with an ugly traceback. Now `pelican --listen` invocations, when quit via CTRL-C, are followed instead by a more user-friendly message.
This commit is contained in:
parent
569f8a080e
commit
fa71931503
1 changed files with 4 additions and 0 deletions
|
|
@ -475,6 +475,10 @@ def listen(server, port, output, excqueue=None):
|
|||
excqueue.put(traceback.format_exception_only(type(e), e)[-1])
|
||||
return
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\nKeyboard interrupt received. Shutting down server.")
|
||||
httpd.socket.close()
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
args = parse_arguments(argv)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue