Files
docker-images/python-tools/app/__main__.py
T
ajp_anton 3bfd199b9c
Build custom container images / build (map[base_image:php:8-fpm-alpine build_args:PHP_VERSION=8 context:php8-pgsql fingerprint_command:{ apk info -v | LC_ALL=C sort; find /usr/local/lib/php/extensions /usr/local/etc/php/conf.d -type f -exec sha256sum {} + | LC_ALL=C sort; } name:ph… (push) Successful in 40s
Build custom container images / build (map[base_image:postgres:18 build_args:PG_VERSION=18 POSTGIS_VERSION=3 VCHORD_VERSION=0.5.3 context:postgres fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; find /usr/lib/postgresql -type f -exec sha256su… (push) Successful in 49s
Build custom container images / build (map[base_image:python:3 build_args:PYTHON_VERSION=3 context:python-tools fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; } name:python-tools oci_labels:org.opencontainers.ima… (push) Successful in 1m37s
Build custom container images / build (map[base_image:python:3.12-slim build_args:PYTHON_VERSION=3.12-slim context:linkki-tiedotus fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; } name:linkki-tiedotus oci_labels:… (push) Successful in 36s
Build custom container images / build (map[base_image:python:3.12-slim build_args:PYTHON_VERSION=3.12-slim context:timepoll fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; } name:timepoll oci_labels:org.opencontai… (push) Successful in 42s
Add cooperative task recovery and persistent live status
2026-10-29 22:12:04 +00:00

53 lines
1.5 KiB
Python

"""Production entry point."""
from __future__ import annotations
import os
import signal
import threading
import time
from waitress import create_server
from .web import create_app
def main() -> None:
stopping = False
requested_at = None
def request_shutdown(_signal, _frame):
nonlocal stopping, requested_at
stopping = True
if requested_at is None:
requested_at = time.monotonic()
signal.signal(signal.SIGTERM, request_shutdown)
signal.signal(signal.SIGINT, request_shutdown)
app, server = None, None
try:
app = create_app()
server = create_server(
app,
host=os.environ.get("SERVER_MAINTENANCE_HOST", "0.0.0.0"),
port=int(os.environ.get("SERVER_MAINTENANCE_PORT", "8080")),
)
thread = threading.Thread(target=server.run, name="http-server", daemon=True)
thread.start()
while not stopping and thread.is_alive():
time.sleep(.1)
finally:
print("Shutdown requested; pausing tasks at safe checkpoints.", flush=True)
if app is not None:
app.extensions["background_scheduler"].stop()
manager = app.extensions["run_manager"]
elapsed = time.monotonic() - requested_at if requested_at is not None else 0
manager.shutdown(timeout=max(0, manager.settings.shutdown_grace_seconds - elapsed))
if server is not None:
server.task_dispatcher.shutdown(timeout=5)
server.close()
if __name__ == "__main__":
main()