Skip to content

Commit

Permalink
Merge pull request #134 from psteniusubi/fix-improve-accept-error-mes…
Browse files Browse the repository at this point in the history
…sage

Improve startup error message when bind on http port fails
  • Loading branch information
m00sey authored Nov 30, 2023
2 parents 453ef52 + d757f40 commit 97c63d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/keria/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def setup(name, bran, adminPort, bootPort, base='', httpPort=None, configFile=No
'signify-resource', 'signify-timestamp']))

bootServer = createHttpServer(bootPort, bootApp, keypath, certpath, cafilepath)
if not bootServer.reopen():
raise RuntimeError(f"cannot create boot http server on port {bootPort}")
bootServerDoer = http.ServerDoer(server=bootServer)
bootEnd = BootEnd(agency)
bootApp.add_route("/boot", bootEnd)
Expand All @@ -77,6 +79,8 @@ def setup(name, bran, adminPort, bootPort, base='', httpPort=None, configFile=No
app.resp_options.media_handlers.update(media.Handlers())

adminServer = createHttpServer(adminPort, app, keypath, certpath, cafilepath)
if not adminServer.reopen():
raise RuntimeError(f"cannot create admin http server on port {adminPort}")
adminServerDoer = http.ServerDoer(server=adminServer)

doers = [agency, bootServerDoer, adminServerDoer]
Expand All @@ -100,6 +104,8 @@ def setup(name, bran, adminPort, bootPort, base='', httpPort=None, configFile=No
indirecting.loadEnds(agency=agency, app=happ)

server = createHttpServer(httpPort, happ, keypath, certpath, cafilepath)
if not server.reopen():
raise RuntimeError(f"cannot create local http server on port {httpPort}")
httpServerDoer = http.ServerDoer(server=server)
doers.append(httpServerDoer)

Expand Down
3 changes: 2 additions & 1 deletion tests/app/test_agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
from keria.core import longrunning


def test_setup():
def test_setup_no_http():
doers = agenting.setup(name="test", bran=None, adminPort=1234, bootPort=5678)
assert len(doers) == 3
assert isinstance(doers[0], agenting.Agency) is True

def test_setup():
doers = agenting.setup("test", bran=None, adminPort=1234, bootPort=5678, httpPort=9999)
assert len(doers) == 4

Expand Down

0 comments on commit 97c63d0

Please sign in to comment.