1.3 KiB
1.3 KiB
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