service-constants.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef SERVICE_CONSTANTS_H
  2. #define SERVICE_CONSTANTS_H
  3. /* Service states */
  4. enum class service_state_t {
  5. STOPPED, // service is not running.
  6. STARTING, // service is starting, and will start (or fail to start) in time.
  7. STARTED, // service is running,
  8. STOPPING // service script is stopping and will stop.
  9. };
  10. /* Service types */
  11. enum class service_type_t {
  12. DUMMY, // Dummy service, used to detect cyclice dependencies
  13. PROCESS, // Service runs as a process, and can be stopped by
  14. // sending the process a signal (usually SIGTERM)
  15. BGPROCESS, // Service runs as a process which "daemonizes" to run in the
  16. // "background".
  17. SCRIPTED, // Service requires an external command to start,
  18. // and a second command to stop
  19. INTERNAL // Internal service, runs no external process
  20. };
  21. /* Service events */
  22. enum class service_event_t {
  23. STARTED, // Service was started (reached STARTED state)
  24. STOPPED, // Service was stopped (reached STOPPED state)
  25. FAILEDSTART, // Service failed to start (possibly due to dependency failing)
  26. STARTCANCELLED, // Service was set to be started but a stop was requested
  27. STOPCANCELLED // Service was set to be stopped but a start was requested
  28. };
  29. /* Shutdown types */
  30. enum class shutdown_type_t {
  31. CONTINUE, // Continue normal boot sequence (used after single-user shell)
  32. HALT, // Halt system without powering down
  33. POWEROFF, // Power off system
  34. REBOOT // Reboot system
  35. };
  36. /* Reasons for why service stopped */
  37. enum class stopped_reason_t
  38. {
  39. NORMAL,
  40. // Start failures:
  41. DEPFAILED, // A dependency failed to start
  42. FAILED, // failed to start (process terminated)
  43. EXECFAILED, // failed to start (couldn't launch process)
  44. TIMEDOUT, // timed out when starting
  45. // Failure after starting:
  46. TERMINATED // process terminated
  47. };
  48. enum class dependency_type
  49. {
  50. REGULAR,
  51. SOFT, // dependency starts in parallel, failure/stop does not affect dependent
  52. WAITS_FOR, // as for SOFT, but dependent waits until dependency starts/fails before starting
  53. MILESTONE // dependency must start successfully, but once started the dependency becomes soft
  54. };
  55. // Service set type identifiers:
  56. constexpr int SSET_TYPE_NONE = 0;
  57. constexpr int SSET_TYPE_DIRLOAD = 1;
  58. #endif