- Add comprehensive testing instructions to README. - Improve error handling in examples to prevent crashes. - Enhance launchctl error handling for production safety. - Improve zinit error handling for production safety. - Remove obsolete plan_to_fix.md file. - Update Rhai integration tests for improved robustness. - Improve service manager creation on Linux with systemd fallback. |
||
---|---|---|
.. | ||
README.md | ||
service_spaghetti.rs | ||
simple_service.rs |
Service Manager Examples
This directory contains examples demonstrating the usage of the sal-service-manager
crate.
Running Examples
To run any example, use the following command structure from the service_manager
crate's root directory:
cargo run --example <EXAMPLE_NAME>
1. simple_service
This example demonstrates the ideal, clean lifecycle of a service using the separated create
and start
steps.
Behavior:
- Creates a new service definition.
- Starts the newly created service.
- Checks its status to confirm it's running.
- Stops the service.
- Checks its status again to confirm it's stopped.
- Removes the service definition.
Run it:
cargo run --example simple_service
2. service_spaghetti
This example demonstrates how the service manager handles "messy" or improper sequences of operations, showcasing its error handling and robustness.
Behavior:
- Creates a service.
- Starts the service.
- Tries to start the same service again (which should fail as it's already running).
- Removes the service without stopping it first (the manager should handle this gracefully).
- Tries to stop the already removed service (which should fail).
- Tries to remove the service again (which should also fail).
Run it:
cargo run --example service_spaghetti