start_daemon and stop_daemon polled "while True" with no bound, and no seaf-cli exit code was checked. A daemon that failed to start left the container spinning forever with nothing pointing at the cause, and there was no signal handling, so "docker stop" waited the full 10 second grace period and then SIGKILLed the process with the daemon still running. Readiness polling is now bounded by DAEMON_START_TIMEOUT and DAEMON_STOP_TIMEOUT. The stop timeout is 8 seconds so a graceful shutdown fits inside the docker stop grace period, and a test asserts that relation. SIGTERM and SIGINT raise GracefulShutdown, and the lifecycle moved into start.run(), which always stops the daemon on the way out and returns the process exit code: 0 on a clean finish or a stop signal, 1 on a daemon or configuration failure. seaf-cli exit codes are checked. A failed sync is reported per library and does not stop the remaining libraries, since one bad library should not take the container down. Verified in the built image: "docker stop" now returns in 0s with exit code 0 and the daemon stopped, against 10s and exit 137 before. A daemon that cannot start exits 1 with the failing command and its exit code in the log. Also bumps actions/setup-python to v7, which clears the last Node 20 deprecation warning; v7 only drops the unused pip-install input.
18 lines
425 B
Python
18 lines
425 B
Python
"""Errors that must end the container with a useful message."""
|
|
|
|
|
|
class DscError(Exception):
|
|
"""Base class for failures that stop the client."""
|
|
|
|
|
|
class DaemonError(DscError):
|
|
"""A seaf-cli command failed."""
|
|
|
|
|
|
class DaemonTimeout(DscError):
|
|
"""The daemon did not reach the expected state in time."""
|
|
|
|
|
|
class GracefulShutdown(DscError):
|
|
"""SIGTERM or SIGINT was received; stop the daemon and exit cleanly."""
|