Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/func_python/cloudevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import os
import signal
import socket
import hypercorn.config
import hypercorn.asyncio

Expand Down Expand Up @@ -74,7 +75,13 @@ def serve(self):
"""serve serving this ASGIhandler, delegating implementation of
methods as necessary to the wrapped Function instance"""
cfg = hypercorn.config.Config()
cfg.bind = [os.getenv('LISTEN_ADDRESS', DEFAULT_LISTEN_ADDRESS)]

la = os.getenv('LISTEN_ADDRESS', DEFAULT_LISTEN_ADDRESS)
[host, port] = la.rsplit(":", 1)
# fixup for IPv4-only machines
if not socket.has_ipv6 and host == '[::]':
la = "0.0.0.0:" + port
cfg.bind = [la]

logging.info(f"function starting on {cfg.bind}")
return asyncio.run(self._serve(cfg))
Expand Down
9 changes: 8 additions & 1 deletion src/func_python/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import os
import signal
import socket
import hypercorn.config
import hypercorn.asyncio

Expand Down Expand Up @@ -69,7 +70,13 @@ def serve(self):
"""serve serving this ASGIhandler, delegating implementation of
methods as necessary to the wrapped Function instance"""
cfg = hypercorn.config.Config()
cfg.bind = [os.getenv('LISTEN_ADDRESS', DEFAULT_LISTEN_ADDRESS)]

la = os.getenv('LISTEN_ADDRESS', DEFAULT_LISTEN_ADDRESS)
[host, port] = la.rsplit(":", 1)
# fixup for IPv4-only machines
if not socket.has_ipv6 and host == '[::]':
la = "0.0.0.0:" + port
cfg.bind = [la]

logging.debug(f"function starting on {cfg.bind}")
return asyncio.run(self._serve(cfg))
Expand Down
Loading