saturnin._scripts.commands.daemons

Typer commands for managing Saturnin daemon processes.

This module provides CLI commands to list currently running Saturnin daemons, show detailed information about a specific daemon process, and stop a running daemon. Daemons are typically Saturnin recipes executed in DAEMON mode.

Globals

saturnin._scripts.commands.daemons.app

Typer command group for daemon management commands

Parameters:
Return type:

Any

Command functions

saturnin._scripts.commands.daemons.list_daemons() None[source]

Lists all currently running Saturnin daemon processes.

Displays a table with the PID, status, associated recipe name, and a brief description of the recipe for each running daemon. If a daemon’s recipe has been uninstalled, it’s marked accordingly.

Return type:

None

saturnin._scripts.commands.daemons.show_daemon(pid: ~typing.Annotated[int, <typer.models.ArgumentInfo object at 0x7092a3308090>]) None[source]

Displays detailed information about a running Saturnin daemon process.

Information includes process status, creation time, resource usage (CPU, memory, I/O), command line, and associated user.

Parameters:

pid (Annotated[int, <typer.models.ArgumentInfo object at 0x7092a3317e90>])

Return type:

None

saturnin._scripts.commands.daemons.stop_daemon(pid: ~typing.Annotated[int, <typer.models.ArgumentInfo object at 0x7092a3489d50>]) None[source]

Stops a running Saturnin daemon process.

This command attempts a graceful shutdown by sending the appropriate signal (SIGINT on Unix, CTRL_C_EVENT on Windows) to the daemon.

Parameters:

pid (Annotated[int, <typer.models.ArgumentInfo object at 0x7092a348bbd0>])

Return type:

None

Functions

saturnin._scripts.commands.daemons.get_first_line(text: str) str[source]

Returns the first non-empty line from the input string.

Parameters:

text (str) – The string from which to extract the first line.

Returns:

The first line of the string, stripped of leading/trailing whitespace. Returns an empty string if the input is empty or only whitespace.

Return type:

str

saturnin._scripts.commands.daemons.get_running_daemons() dict[int, str][source]

Scans Saturnin’s PID directory to identify running daemon processes.

It checks each pid file, reads the associated recipe name, and verifies if the process with that PID is still running using psutil. If a PID file points to a non-existent process, the stale PID file is removed.

Returns:

A dictionary where keys are process IDs (int) of running daemons, and values are the corresponding RecipeInfo objects. If a recipe associated with a running daemon is no longer installed, the value will be None.

Return type:

dict[int, str]

saturnin._scripts.commands.daemons.pid_completer(ctx, args, incomplete) list[tuple[str, str]][source]

Click/Typer autocompletion function for running Saturnin daemon PIDs.

Provides a list of (PID, recipe_name) tuples for autocompletion suggestions.

Parameters:
  • ctx – The Click/Typer context.

  • args – The current command arguments.

  • incomplete – The partially typed PID.

Returns:

A list of tuples, where each tuple contains the PID as a string and the associated recipe name (or an empty string if the recipe is unknown).

Return type:

list[tuple[str, str]]