sal/service_manager/examples
Mahmoud-Emad 502e345f91 feat: Enhance service manager with zinit socket discovery and systemd fallback
- Improve Linux support by automatically discovering zinit sockets
  using environment variables and common paths.
- Add fallback to systemd if no zinit server is detected.
- Enhance README with detailed instructions for zinit usage,
  including custom socket path configuration.
- Add example demonstrating zinit socket discovery.
- Add logging to show socket discovery process.
- Add unit tests for service manager creation and socket discovery.
2025-07-02 16:37:27 +03:00
..
README.md service manager add examples and improvements 2025-07-02 05:50:18 +02:00
service_spaghetti.rs feat: Enhance service manager with zinit socket discovery and systemd fallback 2025-07-02 16:37:27 +03:00
simple_service.rs feat: Enhance service manager with zinit socket discovery and systemd fallback 2025-07-02 16:37:27 +03:00
socket_discovery_test.rs feat: Enhance service manager with zinit socket discovery and systemd fallback 2025-07-02 16:37:27 +03:00

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:

  1. Creates a new service definition.
  2. Starts the newly created service.
  3. Checks its status to confirm it's running.
  4. Stops the service.
  5. Checks its status again to confirm it's stopped.
  6. 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:

  1. Creates a service.
  2. Starts the service.
  3. Tries to start the same service again (which should fail as it's already running).
  4. Removes the service without stopping it first (the manager should handle this gracefully).
  5. Tries to stop the already removed service (which should fail).
  6. Tries to remove the service again (which should also fail).

Run it:

cargo run --example service_spaghetti