Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 1 | namespace aos.starter; |
| 2 | |
| 3 | enum State : short { |
| 4 | // Process has recently stopped and is waiting to restart. |
| 5 | WAITING, |
| 6 | |
| 7 | // Process has forked, waiting to move to RUNNING after verifying it started |
| 8 | // successfully. |
| 9 | STARTING, |
| 10 | |
| 11 | // Process is running. pid, id, and last_start_time represent the current |
| 12 | // running process. |
| 13 | RUNNING, |
| 14 | |
| 15 | // Process has been sent SIGTERM to nicely stop and starter is waiting for it |
| 16 | // to exit. |
| 17 | STOPPING, |
| 18 | |
| 19 | // Process is stopped and will not automatically restart unless sent a command |
| 20 | STOPPED |
| 21 | } |
| 22 | |
| 23 | enum LastStopReason : uint { |
| 24 | // Application received stop command message |
| 25 | STOP_REQUESTED, |
| 26 | |
| 27 | // Application received restart command message |
| 28 | RESTART_REQUESTED, |
| 29 | |
| 30 | // Application terminated - only occurs when starter is shutting down |
| 31 | TERMINATE, |
| 32 | |
| 33 | // System failed to fork and create a new process |
| 34 | FORK_ERR, |
| 35 | |
| 36 | // Failed to set parent death handler on child |
| 37 | SET_PRCTL_ERR, |
| 38 | |
| 39 | // Failed to change to the requested user |
| 40 | SET_USR_ERR, |
| 41 | |
| 42 | // Failed to execute application - likely due to a missing executable or |
| 43 | // invalid permissions. This is not reported if an application dies for |
| 44 | // another reason after it is already running. |
Austin Schuh | 529ac59 | 2021-10-14 16:11:13 -0700 | [diff] [blame] | 45 | EXECV_ERR, |
| 46 | |
| 47 | // Failed to change to the requested group |
James Kuszmaul | 6f10b38 | 2022-03-11 22:31:38 -0800 | [diff] [blame^] | 48 | SET_GRP_ERR |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | table Status { |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 52 | statuses: [ApplicationStatus] (id: 0); |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | table ApplicationStatus { |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 56 | name: string (id: 0); |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 57 | |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 58 | state: State (id: 1); |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 59 | |
| 60 | // Last exit code of the process. Has a value of 0 if not started. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 61 | last_exit_code: ubyte (id: 2); |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 62 | |
| 63 | // Last pid of the process. Could be associated with a different process |
| 64 | // unless status == RUNNING. Not present if the process has not started. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 65 | pid: uint (id: 3); |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 66 | |
| 67 | // Unique id of this application and process |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 68 | id: uint64 (id: 4); |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 69 | |
| 70 | // Start time in nanoseconds relative to monotonic clock |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 71 | last_start_time: int64 (id: 5); |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 72 | |
| 73 | // Indicates the reason the application is not running. Only valid if |
| 74 | // application is STOPPED. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 75 | last_stop_reason: LastStopReason (id: 6); |
Tyler Chatow | a79419d | 2020-08-12 20:12:11 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | root_type Status; |