michaelmelanson / michaelmelanson/panda-os
Service manager step 7: Service manager core (event loop and lifecycle)
- Dominant language
- Rust
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
Implement the service manager core event loop in `init` that executes plan steps, handles process exits, restart timers, stop grace periods, log forwarding, and command dispatch. All events flow through a single mailbox.
This is step 7 of the service manager implementation (#26). Depends on steps 1-6.
## Desired behaviour
The service manager runs as the main loop in `init` and handles:
- **Plan execution**: Starts/stops/restarts services according to the planner output
- **Process exit handling**: Detects when a service exits, applies restart policy
- **Restart timers**: Exponential backoff for restarting failed services (uses timer resource from #28)
- **Stop grace periods**: Sends SIGTERM, waits grace period, then SIGKILL if still running
- **Log forwarding**: Captures service stdout/stderr and forwards to system log
- **Command dispatch**: Receives management commands from `svcctl` via the manager protocol
## Event sources (all on one mailbox)
- Process exit events
- Timer expiry events (restart backoff, stop grace period)
- Management API channel messages
- Service connection requests
## Key files
- `userspace/init/src/manager.rs` — service manager core
- `userspace/init/src/main.rs` — wire up the event loop
- Uses planner from #32, configs from #31, timers from #28, signals from #27
## Testing
- Integration test: boot with service configs, verify services start in dependency order
- Integration test: kill a service with `restart = "always"`, verify it restarts
- Integration test: kill a service with `restart = "never"`, verify it stays down
- Integration test: stop grace period — service that ignores SIGTERM gets SIGKILL after timeout
- Test log forwarding captures service output
## Documentation
- Document the event loop architecture and event sources
- Document restart policies and backoff behaviour
- Document the log forwarding mechanism
Part of #26
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading userspace/init/src/manager.rs and userspace/init/src/main.rs, then review the planner, config, timer, and signal components from issues #32, #31, #28, and #27. Implement the single-mailbox event loop for plan execution, exits, timers, commands, connections, and log forwarding. Done means the listed integration cases pass and the event-loop, restart-policy, and log-forwarding behavior is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100