feat: configurable port, use HUB_DATA and HUB_PORT env vars
This commit is contained in:
1 parent
6be745a6f4
commit
248146056a
5 files changed
+16
-12
No files matched your search
+4
-3
@@ -437,9 +437,10 @@ class App(ChatMixin):
|
||||
|
||||
async def main():
|
||||
# Get data directory from environment variable
|
||||
data_directory = os.getenv("HORDE_DATA_DIR")
|
||||
data_directory = os.getenv("HUB_DATA")
|
||||
if not data_directory:
|
||||
raise ValueError("HORDE_DATA_DIR environment variable must be set")
|
||||
raise ValueError("HUB_DATA environment variable must be set")
|
||||
port = os.getenv("HUB_PORT", 17922)
|
||||
|
||||
# 1. Initialize Database First
|
||||
await db.init_database(data_directory)
|
||||
@@ -456,7 +457,7 @@ async def main():
|
||||
# manually trigger server shutdown, avoids hypercorn installing signal handlers
|
||||
shutdown_event = asyncio.Event()
|
||||
# TODO: get port from env or don't pass it (actually server should handle none)
|
||||
server_task = asyncio.create_task(start_server(horde_app, shutdown_event))
|
||||
server_task = asyncio.create_task(start_server(horde_app, port, shutdown_event))
|
||||
|
||||
# 4. Graceful Termination
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
@@ -23,7 +23,9 @@ def tortoise_config(data_directory):
|
||||
}
|
||||
|
||||
# Only used for tortoise tool
|
||||
TORTOISE_ORM=tortoise_config(os.getenv("HORDE_DATA_DIR"))
|
||||
# TODO: Should move somewhere tool specific and using the same directory as app
|
||||
# computing this here unconditionally is dirty
|
||||
TORTOISE_ORM=tortoise_config(os.getenv("HUB_DATA"))
|
||||
|
||||
# Considering creating a migration script "makemigration.py" or similar, that will load the config and make migration
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ def encode_json(value):
|
||||
return repr(value)
|
||||
return json.dumps(value, default=encode_unknown)
|
||||
|
||||
async def start_server(app, shutdown_event, port=17922):
|
||||
async def start_server(app, port, shutdown_event):
|
||||
server = Quart(__name__, static_folder=frontend_path)
|
||||
server.secret_key = 'horde-secret'
|
||||
auth_manager = QuartAuth(server, mode="bearer")
|
||||
|
||||
Reference in new issue
Block a user