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