archivebox.workers.supervisord_util

Module Contents

Classes

SupervisordConnectionCache

Reuse one XML-RPC proxy until it fails, avoiding hot-loop reconnects.

Functions

_shell_join

_record_supervisord_process

_fallback_supervisord_process_from_db

_live_supervisord_processes_from_db

Return live supervisord parents recorded for this DATA_DIR.

_stop_older_supervisord_processes

Stop older supervisord parents for this DATA_DIR after a start race.

RUNSERVER_WORKER

is_port_in_use

Check if a port is already in use.

_sonic_worker_bind_target

Read the plugin-owned Sonic config before starting its supervisord worker.

get_sock_file

Get the path to the supervisord socket file, symlinking to a shorter path if needed due to unix path length limits

create_supervisord_config

create_worker_config

Create a supervisord worker config file for a given daemon

_current_foreground_supervisord_process_id

sync_supervisord_workers

Project desired workers into supervisord from ArchiveBox-owned state.

get_existing_supervisord_process

stop_existing_supervisord_process

stop_own_supervisord_process

Stop only the supervisord child started by this Python process.

reap_foreground_supervisord_process

Reap the supervisord child owned by this foreground parent if it exited.

start_new_supervisord_process

wait_for_supervisord_ready

Poll for supervisord readiness without a fixed startup sleep.

get_or_create_supervisord_process

start_worker

run_runner_worker

get_worker

format_runtime_components

worker_runtime_component

runtime_components_for_worker_names

active_supervisord_runtime_components

build_server_worker_plan

stop_worker

tail_multiple_worker_logs

Tail multiple log files simultaneously, interleaving their output.

get_sonic_supervisord_worker_from_plugin

_proc_cmdline

_is_sonic_process

_is_supervisord_process

_has_live_archivebox_parent

_terminate_process_tree

_sonic_listeners

stop_stale_sonic_processes

start_server_workers

Data

LOG_FILE_NAME

CONFIG_FILE_NAME

PID_FILE_NAME

WORKERS_DIR_NAME

_supervisord_proc

_desired_supervisord_workers

_ACTIVE_WORKER_STATES

_RUNTIME_COMPONENT_ORDER

RUNNER_WORKER

RUNNER_ONCE_WORKER

RUNNER_WATCH_WORKER

SUPERVISORD_PARENT_WATCHDOG_WORKER

SERVER_WORKER

API

archivebox.workers.supervisord_util.LOG_FILE_NAME[source]

β€˜supervisord.log’

archivebox.workers.supervisord_util.CONFIG_FILE_NAME[source]

β€˜supervisord.conf’

archivebox.workers.supervisord_util.PID_FILE_NAME[source]

β€˜supervisord.pid’

archivebox.workers.supervisord_util.WORKERS_DIR_NAME[source]

β€˜workers’

archivebox.workers.supervisord_util._supervisord_proc[source]

None

archivebox.workers.supervisord_util._desired_supervisord_workers: dict[str, dict[str, str]][source]

None

archivebox.workers.supervisord_util._ACTIVE_WORKER_STATES[source]

None

archivebox.workers.supervisord_util._RUNTIME_COMPONENT_ORDER[source]

(β€˜orchestrator’, β€˜server’, β€˜sonic’)

archivebox.workers.supervisord_util._shell_join(args: list[str]) str[source]
archivebox.workers.supervisord_util._record_supervisord_process(proc: subprocess.Popen, config_file: pathlib.Path) None[source]
archivebox.workers.supervisord_util._fallback_supervisord_process_from_db()[source]
archivebox.workers.supervisord_util._live_supervisord_processes_from_db()[source]

Return live supervisord parents recorded for this DATA_DIR.

The socket/config files are generated runtime projection and can move when TMP_DIR changes or falls back. Process rows are the durable coordination state, so takeover/shutdown must stop every live supervisord recorded for this collection, not only the one reachable at the current socket path.

archivebox.workers.supervisord_util._stop_older_supervisord_processes(*, current_pid: int, current_started_at: float, timeout: float) None[source]

Stop older supervisord parents for this DATA_DIR after a start race.

Lazy daemon users such as archivebox list --search ... may race to start Sonic. The durable Process table is the arbiter: after this parent is recorded, kill only live supervisord rows that started before this one. If another parent started later, leave it alone so newest healthy owner wins.

archivebox.workers.supervisord_util.RUNNER_WORKER[source]

None

archivebox.workers.supervisord_util.RUNNER_ONCE_WORKER[source]

None

archivebox.workers.supervisord_util.RUNNER_WATCH_WORKER[source]

None

archivebox.workers.supervisord_util.SUPERVISORD_PARENT_WATCHDOG_WORKER[source]

None

archivebox.workers.supervisord_util.SERVER_WORKER[source]

None

archivebox.workers.supervisord_util.RUNSERVER_WORKER(host: str, port: str, *, reload: bool, nothreading: bool = False)[source]
archivebox.workers.supervisord_util.is_port_in_use(host: str, port: int) bool[source]

Check if a port is already in use.

archivebox.workers.supervisord_util._sonic_worker_bind_target(worker: dict[str, str]) tuple[str, int] | None[source]

Read the plugin-owned Sonic config before starting its supervisord worker.

archivebox.workers.supervisord_util.get_sock_file()[source]

Get the path to the supervisord socket file, symlinking to a shorter path if needed due to unix path length limits

archivebox.workers.supervisord_util.create_supervisord_config()[source]
archivebox.workers.supervisord_util.create_worker_config(daemon)[source]

Create a supervisord worker config file for a given daemon

archivebox.workers.supervisord_util._current_foreground_supervisord_process_id()[source]
archivebox.workers.supervisord_util.sync_supervisord_workers(supervisor, workers: list[tuple[dict[str, str], bool]], *, prune: bool = True)[source]

Project desired workers into supervisord from ArchiveBox-owned state.

The worker conf files are generated supervisor input only. They are never treated as durable ArchiveBox state; callers either pass a complete worker set with prune=True or add one explicit worker with prune=False.

archivebox.workers.supervisord_util.get_existing_supervisord_process(*, quiet: bool = False)[source]
class archivebox.workers.supervisord_util.SupervisordConnectionCache(*, quiet: bool = False)[source]

Reuse one XML-RPC proxy until it fails, avoiding hot-loop reconnects.

Initialization

clear() None[source]
get()[source]
archivebox.workers.supervisord_util.stop_existing_supervisord_process()[source]
archivebox.workers.supervisord_util.stop_own_supervisord_process(*, record_exit: bool = True)[source]

Stop only the supervisord child started by this Python process.

archivebox.workers.supervisord_util.reap_foreground_supervisord_process() None[source]

Reap the supervisord child owned by this foreground parent if it exited.

archivebox.workers.supervisord_util.start_new_supervisord_process(daemonize=False)[source]
archivebox.workers.supervisord_util.wait_for_supervisord_ready(max_wait_sec: float = 5.0, interval_sec: float = 0.1, *, quiet: bool = False)[source]

Poll for supervisord readiness without a fixed startup sleep.

archivebox.workers.supervisord_util.get_or_create_supervisord_process(daemonize=False)[source]
archivebox.workers.supervisord_util.start_worker(supervisor, daemon, lazy=False)[source]
archivebox.workers.supervisord_util.run_runner_worker(args: list[str], *, name: str = 'worker_runner_once', interactive_interrupts: bool = False) int[source]
archivebox.workers.supervisord_util.get_worker(supervisor, daemon_name)[source]
archivebox.workers.supervisord_util.format_runtime_components(components: list[str] | tuple[str, ...]) str[source]
archivebox.workers.supervisord_util.worker_runtime_component(worker_name: str, *, config=None) str | None[source]
archivebox.workers.supervisord_util.runtime_components_for_worker_names(worker_names: set[str] | list[str] | tuple[str, ...], *, config=None) list[str][source]
archivebox.workers.supervisord_util.active_supervisord_runtime_components(*, config=None, supervisor=None) list[str][source]
archivebox.workers.supervisord_util.build_server_worker_plan(*, config, host: str, port: str, debug: bool, reload: bool, nothreading: bool, supervisor=None)[source]
archivebox.workers.supervisord_util.stop_worker(supervisor, daemon_name)[source]
archivebox.workers.supervisord_util.tail_multiple_worker_logs(log_files: list[str], follow=True, proc=None, keep_running=None)[source]

Tail multiple log files simultaneously, interleaving their output.

Args: log_files: List of log file paths to tail follow: Whether to keep following (True) or just read existing content (False) proc: Optional subprocess.Popen object - stop tailing when this process exits

archivebox.workers.supervisord_util.get_sonic_supervisord_worker_from_plugin(config) dict[str, str] | None[source]
archivebox.workers.supervisord_util._proc_cmdline(proc: psutil.Process) list[str][source]
archivebox.workers.supervisord_util._is_sonic_process(proc: psutil.Process) bool[source]
archivebox.workers.supervisord_util._is_supervisord_process(proc: psutil.Process | None) bool[source]
archivebox.workers.supervisord_util._has_live_archivebox_parent(proc: psutil.Process | None) bool[source]
archivebox.workers.supervisord_util._terminate_process_tree(root: psutil.Process, *, timeout: float = 2.0) None[source]
archivebox.workers.supervisord_util._sonic_listeners(host: str, port: int) list[psutil.Process][source]
archivebox.workers.supervisord_util.stop_stale_sonic_processes(sonic_worker: dict[str, str], *, supervisor_pid: int | None, host: str | None = None, port: int | None = None) None[source]
archivebox.workers.supervisord_util.start_server_workers(host='0.0.0.0', port='8000', daemonize=False, debug=False, reload=False, nothreading=False, keep_running=None, should_stop_supervisord=None, resumed_from_pid=None)[source]