* Add a health check for the daemon and RPC endpoint SeafileClient.is_healthy() checks seaf-cli status and makes a real RPC call (get_repo_list) against the daemon's Unix socket - neither needs the Seafile server, so it works without a token or password. healthcheck.py exposes it as a plain script for Docker's HEALTHCHECK. Each check is a fresh process spawned by the Docker daemon as root, unlike the long-lived start.py process, so it drops to the seafile user with runuser before touching the RPC socket - the one place that mechanism still belongs after the earlier in-process privilege drop. Verified against the real image: healthcheck.py exits 0 once the real daemon is up (through the actual main() entrypoint, not a test fixture) and nonzero when no daemon has been started. * Assert the return value in the daemon-down health check test Copilot review: the test checked the RPC call was skipped but not what is_healthy() actually returned in that case. --------- Co-authored-by: Maxim Shulga <maxim.shulga@alludo.com>
22 lines
540 B
Python
22 lines
540 B
Python
#!/usr/bin/env python3
|
|
"""Docker HEALTHCHECK entry point.
|
|
|
|
Exits 0 if the seafile daemon and its RPC socket both respond, 1 otherwise.
|
|
Runs as a separate, short-lived process on every check, so it needs no
|
|
credentials and touches no state the main process owns.
|
|
"""
|
|
|
|
import sys
|
|
|
|
from dsc import const
|
|
from dsc.client import SeafileClient
|
|
|
|
|
|
def main() -> int:
|
|
client = SeafileClient(host="unused", user="unused", app_dir=const.DEFAULT_APP_DIR)
|
|
return 0 if client.is_healthy() else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|