palyrad), the browser automation daemon (palyra-browserd), and the local palyra node host. The supervisor ensures these sidecars remain healthy, handles log aggregation with sensitive data redaction, and implements an exponential backoff strategy for service recovery.
ControlCenter Architecture
TheControlCenter struct is the primary state container for the supervisor, managed within a Tauri State and wrapped in a Mutex for thread-safe access from async commands apps/desktop/src-tauri/src/commands.rs#63-65. It maintains the runtime configuration, service handles, and log buffers.
Key Components
- ManagedService: Tracks the state of an individual sidecar, including its
Childprocess handle, PID, and restart metrics apps/desktop/src-tauri/src/supervisor.rs#108-118. - Supervisor Loop: A 500ms tick loop that evaluates the state of all desired services apps/desktop/src-tauri/src/lib.rs#1-1.
- Log Draining: A multi-producer, single-consumer (
mpsc) pipeline for aggregating stdout/stderr from sidecars into a unified, size-bounded buffer apps/desktop/src-tauri/src/supervisor.rs#231-232.
Service Entity Mapping
| System Name | Code Entity (ServiceKind) | Binary Name | Role |
|---|---|---|---|
| Gateway | ServiceKind::Gateway | palyrad | Central control plane and API provider apps/desktop/src-tauri/src/supervisor.rs#54-54. |
| Browser | ServiceKind::Browserd | palyra-browserd | Headless Chrome automation service apps/desktop/src-tauri/src/supervisor.rs#55-55. |
| Node Host | ServiceKind::NodeHost | palyra node host | Local capability execution host apps/desktop/src-tauri/src/supervisor.rs#56-56. |
ManagedService Lifecycle
Each sidecar is modeled as aManagedService. The supervisor transitions services between states based on the desired_running flag and the actual process status.
Restart Strategy: Exponential Backoff
When a service fails, the supervisor incrementsrestart_attempt and calculates a delay using compute_backoff_ms.
- Base delay: 1,000ms.
- Scaling: , capped at 30,000ms apps/desktop/src-tauri/src/supervisor.rs#445-455.
- Reset: The attempt counter resets to 0 if the service remains healthy for more than 60 seconds apps/desktop/src-tauri/src/supervisor.rs#435-443.
Lifecycle State Machine
Sources: apps/desktop/src-tauri/src/supervisor.rs#120-148, apps/desktop/src-tauri/src/supervisor.rs#445-465, apps/desktop/src-tauri/src/lib.rs#1-1Log Management and Sanitization
The supervisor capturesstdout and stderr from sidecars using Stdio::piped() apps/desktop/src-tauri/src/supervisor.rs#520-521.
Data Flow
- Capture:
tokio::io::BufReaderreads lines from the process pipes apps/desktop/src-tauri/src/supervisor.rs#17-18. - Sanitization: Every line is passed through
sanitize_log_line, which redacts:- Admin tokens and auth headers.
- URLs containing sensitive credentials.
- Known secret patterns apps/desktop/src-tauri/src/snapshot.rs#11-16.
- Ingestion: Sanitized lines are sent via
log_txto theControlCenter’s internallog_rxreceiver apps/desktop/src-tauri/src/supervisor.rs#231-232. - Storage: Lines are stored in a
VecDeque<LogLine>per service, capped atMAX_LOG_LINES_PER_SERVICE(400 lines) to prevent memory exhaustion apps/desktop/src-tauri/src/lib.rs#2-2.
Sidecar Specifics
palyrad (Gateway)
The primary sidecar. It is launched with essential environment variables includingPALYRA_ADMIN_TOKEN and PALYRA_BROWSER_AUTH_TOKEN to secure the internal gRPC and HTTP surfaces apps/desktop/src-tauri/src/supervisor.rs#560-580. It binds to ports 7142 (Admin), 7443 (gRPC), and 7444 (QUIC) by default apps/desktop/src-tauri/src/lib.rs#16-18.
palyra-browserd
Managed based on thebrowser_service_enabled preference in DesktopStateFile. If enabled, the supervisor ensures it is running and healthy, binding to ports 7143 (Health) and 7543 (gRPC) apps/desktop/src-tauri/src/lib.rs#19-20.
palyra node host
The supervisor manages the local node host using the CLI binary.- Enrollment: Invokes
palyra node installto setup local identity material apps/desktop/README.md#56-58. - Execution: Runs
palyra node run --jsonto allow the supervisor to parse machine-readable status updates from the node host apps/desktop/README.md#58-58.