Skip to content

Commit

Permalink
Merge pull request #4 from Netflix/config-ports
Browse files Browse the repository at this point in the history
make host and port for metadata service configurable
  • Loading branch information
ferras committed Jan 28, 2020
2 parents 334d2c7 + 653de0b commit 55710a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
image: "metadata_service:latest"
container_name: "metadata_service"
ports:
- "5004:5004"
- "${MF_METADATA_PORT:-8080}:${MF_METADATA_PORT:-8080}"
volumes:
- .:/code
environment:
Expand All @@ -13,6 +13,8 @@ services:
- MF_METADATA_DB_USER=postgres
- MF_METADATA_DB_PSWD=postgres
- MF_METADATA_DB_NAME=postgres
- MF_METADATA_PORT=${MF_METADATA_PORT:-8080}
- MF_METADATA_HOST=${MF_METADATA_HOST:-0.0.0.0}
links:
- db
db:
Expand Down
5 changes: 4 additions & 1 deletion metadata_service/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import os

from aiohttp import web
from aiohttp_swagger import *
Expand Down Expand Up @@ -36,7 +37,9 @@ def app(loop=None):
loop = asyncio.get_event_loop()
the_app = app(loop)
handler = the_app.make_handler()
f = loop.create_server(handler, "0.0.0.0", 8080)
port = os.environ.get("MF_METADATA_PORT", 8080)
host = str(os.environ.get("MF_METADATA_HOST", "0.0.0.0"))
f = loop.create_server(handler, host, port)

srv = loop.run_until_complete(f)
print("serving on", srv.sockets[0].getsockname())
Expand Down

0 comments on commit 55710a0

Please sign in to comment.