start_app + run_app
This commit is contained in:
parent
0351d26064
commit
0af1adc5fe
@ -1,10 +1,8 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from aiohttp import web
|
|
||||||
|
|
||||||
from v6d0auth.app import get_app
|
from v6d0auth.app import get_app
|
||||||
from v6d0auth.config import port, host
|
from v6d0auth.run_app import run_app
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
web.run_app(get_app(loop), host=host, port=port, loop=loop)
|
loop.run_until_complete(run_app(get_app(loop)))
|
||||||
|
25
v6d0auth/run_app.py
Normal file
25
v6d0auth/run_app.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import asyncio
|
||||||
|
|
||||||
|
from aiohttp import web
|
||||||
|
|
||||||
|
from v6d0auth.config import port, host
|
||||||
|
|
||||||
|
__all__ = ('start_app', 'run_app',)
|
||||||
|
|
||||||
|
|
||||||
|
async def start_app(app: web.Application):
|
||||||
|
runner = web.AppRunner(app)
|
||||||
|
await runner.setup()
|
||||||
|
site = web.TCPSite(runner, host=host, port=port)
|
||||||
|
await site.start()
|
||||||
|
names = sorted(str(s.name) for s in runner.sites)
|
||||||
|
print(
|
||||||
|
"======== Running on {} ========\n"
|
||||||
|
"(Press CTRL+C to quit)".format(", ".join(names))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def run_app(app: web.Application):
|
||||||
|
await start_app(app)
|
||||||
|
while True:
|
||||||
|
await asyncio.sleep(3600)
|
Loading…
Reference in New Issue
Block a user