Skip to content

Commit

Permalink
Merge pull request #330 from EGA-archive/develop
Browse files Browse the repository at this point in the history
Unblocking API
  • Loading branch information
costero-e authored May 24, 2024
2 parents ea9ba3e + ff5e575 commit 8c5f40c
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions beacon/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
from aiohttp_middlewares import cors_middleware
from aiohttp_middlewares.cors import DEFAULT_ALLOW_HEADERS

import asyncio
import socket

from beacon import conf, load_logger
from beacon.request import ontologies
from beacon.response import middlewares
Expand Down Expand Up @@ -52,7 +55,7 @@ async def destroy(app):
client.close()


def main(path=None):
async def main(path=None):
# Configure the logging
load_logger()

Expand Down Expand Up @@ -160,24 +163,32 @@ def main(path=None):
if os.path.exists(path):
os.unlink(path)
# will create the UDS socket and bind to it
web.run_app(beacon, path=path, shutdown_timeout=0, ssl_context=ssl_context)
#web.run_app(beacon, path=path, shutdown_timeout=0, ssl_context=ssl_context)
runner = web.AppRunner(beacon)
await runner.setup()
site = web.TCPSite(runner, conf.beacon_host, conf.beacon_port)
await site.start()
while True:
await asyncio.sleep(3600)
else:
static_files = Path(__file__).parent.parent.resolve() / "ui" / "static"
beacon.add_routes([web.static("/static", str(static_files))])

'''
web.run_app(
beacon,
host=getattr(conf, "beacon_host", "0.0.0.0"),
port=getattr(conf, "beacon_port", 5050),
shutdown_timeout=0,
ssl_context=ssl_context,
)

'''
runner = web.AppRunner(beacon)
await runner.setup()
site = web.TCPSite(runner, conf.beacon_host, conf.beacon_port)
await site.start()
while True:
await asyncio.sleep(3600)

if __name__ == "__main__":
# Unix socket
if len(sys.argv) > 1:
main(path=sys.argv[1])
# host:port
else:
main()

asyncio.run(main())

0 comments on commit 8c5f40c

Please sign in to comment.