manga matching and WebApp
This commit is contained in:
@@ -24,6 +24,9 @@ Environment variables
|
||||
SETTLE_SECONDS default 600 (10-minute quiet window)
|
||||
REQUEST_TIMEOUT default 30
|
||||
DELETE_SOURCE default true (delete source folders after pack)
|
||||
MATCH_PATH default /config/matches.json
|
||||
WEB_PORT default 8080 (Flask web UI for matches.json)
|
||||
WEB_HOST default 0.0.0.0
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -38,6 +41,8 @@ sys.path.insert(0, str(Path(__file__).resolve().parent / "src"))
|
||||
|
||||
from src.SuwayomiMover import SuwayomiMover # noqa: E402
|
||||
from src.SuwayomiFolderWatcher import SuwayomiFolderWatcher # noqa: E402
|
||||
from src.MatchesCache import MatchesCache # noqa: E402
|
||||
from src.MatchesWebApp import MatchesWebApp # noqa: E402
|
||||
|
||||
|
||||
def _env_str(name: str, default: "str | None" = None,
|
||||
@@ -77,6 +82,9 @@ def main() -> int:
|
||||
settle_seconds = _env_int("SETTLE_SECONDS", 600)
|
||||
request_timeout = _env_int("REQUEST_TIMEOUT", 30)
|
||||
delete_source = _env_bool("DELETE_SOURCE", True)
|
||||
match_path = _env_str("MATCH_PATH", "/config/matches.json")
|
||||
web_host = _env_str("WEB_HOST", "0.0.0.0") or "0.0.0.0"
|
||||
web_port = _env_int("WEB_PORT", 8080)
|
||||
|
||||
print(f"[main] suwayomi = {suwayomi_path}", flush=True)
|
||||
print(f"[main] kavita = {kavita_path}", flush=True)
|
||||
@@ -84,6 +92,10 @@ def main() -> int:
|
||||
print(f"[main] settle = {settle_seconds}s", flush=True)
|
||||
print(f"[main] language = {language}", flush=True)
|
||||
print(f"[main] delete src= {delete_source}", flush=True)
|
||||
print(f"[main] match path= {match_path}", flush=True)
|
||||
print(f"[main] web = {web_host}:{web_port}", flush=True)
|
||||
|
||||
matches_cache = MatchesCache(match_path)
|
||||
|
||||
mover = SuwayomiMover(
|
||||
suwayomi_path, kavita_path,
|
||||
@@ -92,20 +104,23 @@ def main() -> int:
|
||||
language=language,
|
||||
request_timeout=request_timeout,
|
||||
delete_source=delete_source,
|
||||
matches_cache=matches_cache,
|
||||
)
|
||||
|
||||
watcher = SuwayomiFolderWatcher(
|
||||
suwayomi_path, mover, settle_seconds=settle_seconds)
|
||||
# watcher = SuwayomiFolderWatcher(suwayomi_path, mover, settle_seconds=settle_seconds)
|
||||
|
||||
def shutdown(signum, _frame):
|
||||
print(f"[main] received signal {signum}", flush=True)
|
||||
watcher.stop()
|
||||
web_app = MatchesWebApp(matches_cache, mover=mover, host=web_host, port=web_port)
|
||||
web_app.start()
|
||||
|
||||
signal.signal(signal.SIGTERM, shutdown)
|
||||
signal.signal(signal.SIGINT, shutdown)
|
||||
|
||||
watcher.start()
|
||||
watcher.wait() # blocks until stop() is called via a signal
|
||||
# def shutdown(signum, _frame):
|
||||
# print(f"[main] received signal {signum}", flush=True)
|
||||
# watcher.stop()
|
||||
#
|
||||
# signal.signal(signal.SIGTERM, shutdown)
|
||||
# signal.signal(signal.SIGINT, shutdown)
|
||||
#
|
||||
# watcher.start()
|
||||
# watcher.wait() # blocks until stop() is called via a signal
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user