diff options
author | Adam Spiers <git@adamspiers.org> | 2021-04-04 01:48:00 +0100 |
---|---|---|
committer | Adam Spiers <git@adamspiers.org> | 2021-04-04 01:52:39 +0100 |
commit | 5dd7f4c4b6d4d771c5b6866b8256eb1bad632843 (patch) | |
tree | 8d5f2d476fb515a0dd2fbda3b6b783387ab969c8 /git_deps | |
parent | 66c1aeb021716c47b8b4a38a8e9cb14826bb60c0 (diff) | |
download | git-deps-5dd7f4c4b6d4d771c5b6866b8256eb1bad632843.tar.gz |
Handle server port in use error more gracefully (#88)
Fixes #88
Diffstat (limited to 'git_deps')
-rw-r--r-- | git_deps/server.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/git_deps/server.py b/git_deps/server.py index 20cc226..694083e 100644 --- a/git_deps/server.py +++ b/git_deps/server.py @@ -1,5 +1,6 @@ import os import subprocess +import sys from git_deps.gitutils import GitUtils from git_deps.detector import DependencyDetector @@ -122,5 +123,17 @@ def serve(options): "insecure!") print("!! Arbitrary code can be executed from browser!") print() - webserver.run(port=options.port, debug=options.debug, - host=options.bindaddr) + try: + webserver.run(port=options.port, debug=options.debug, + host=options.bindaddr) + except OSError as e: + print("\n!!! ERROR: Could not start server:") + print("!!!") + print("!!! " + str(e)) + print("!!!") + if e.strerror == "Address already in use": + print("!!! Do you already have a git deps server running?") + print("!!! If so, stop it first and try again.") + print("!!!") + print("!!! Aborting.") + sys.exit(1) |