Moves entry-point

This commit is contained in:
Oleg Silkin 2019-05-25 22:44:27 -04:00
parent 9144c632d1
commit 46f422272d
3 changed files with 21 additions and 26 deletions

18
compile.py Normal file
View file

@ -0,0 +1,18 @@
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [
Extension("src.database", ["src/database.py"]),
Extension("src.settings", ["src/settings.py"]),
Extension("src.writes", ["src/writes.py"]),
Extension("src.handles", ["src/handles.py"]),
Extension("schema.db_helpers", ["schema/db_helpers.py"]),
Extension("src.app", ["src/app.py"])
] # might need to add some external imports here too
setup(
name="comment_server",
cmdclass={"build_ext": build_ext},
ext_modules=ext_modules
)

2
main.py Normal file
View file

@ -0,0 +1,2 @@
from src.app import run_app
run_app()

View file

@ -90,28 +90,7 @@ def create_app(conf, db_path='DEFAULT', **kwargs):
return app
async def stop_app(runner):
logger.info('stopping app; running cleanup routine')
await runner.cleanup()
async def run_app(app):
runner = None
try:
runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(runner, config['HOST'], config['PORT'])
await site.start()
while True:
await asyncio.sleep(2**63)
except asyncio.CancelledError as cerr:
pass
finally:
await stop_app(runner)
def __run_app():
def run_app():
appl = create_app(conf=config, db_path='TEST', close_timeout=5.0)
try:
asyncio.run(web.run_app(appl, access_log=logger, host=config['HOST'], port=config['PORT']))
@ -119,7 +98,3 @@ def __run_app():
pass
except ValueError:
pass
if __name__ == '__main__':
__run_app()