Skip to content

Commit 97c63d0

Browse files
authored
Merge pull request WebOfTrust#134 from psteniusubi/fix-improve-accept-error-message
Improve startup error message when bind on http port fails
2 parents 453ef52 + d757f40 commit 97c63d0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/keria/app/agenting.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def setup(name, bran, adminPort, bootPort, base='', httpPort=None, configFile=No
5959
'signify-resource', 'signify-timestamp']))
6060

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

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

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

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

tests/app/test_agenting.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
from keria.core import longrunning
2929

3030

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

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

0 commit comments

Comments
 (0)