Skip to content

Commit

Permalink
Handle server port in use error more gracefully (#88)
Browse files Browse the repository at this point in the history
Fixes #88
  • Loading branch information
aspiers committed Apr 4, 2021
1 parent 66c1aeb commit 5dd7f4c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions git_deps/server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import subprocess
import sys

from git_deps.gitutils import GitUtils
from git_deps.detector import DependencyDetector
Expand Down Expand Up @@ -122,5 +123,17 @@ def deps(revspec):
"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)

0 comments on commit 5dd7f4c

Please sign in to comment.