blob: 168b7760354c0b20f74973d47c405bb70399e57a [file] [log] [blame]
James Kuszmaul6295a642022-03-22 15:23:59 -07001include "aos/util/process_info.fbs";
2
Tyler Chatowa79419d2020-08-12 20:12:11 -07003namespace aos.starter;
4
5enum 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
25enum 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 Schuh529ac592021-10-14 16:11:13 -070047 EXECV_ERR,
48
49 // Failed to change to the requested group
James Kuszmaul6f10b382022-03-11 22:31:38 -080050 SET_GRP_ERR
Tyler Chatowa79419d2020-08-12 20:12:11 -070051}
52
James Kuszmaul37a56af2023-07-29 15:15:16 -070053// Used to indicate the current state of the file being executed, so that we
54// can track which executables may need to be restarted.
55enum FileState : short {
56 // We are not currently in the RUNNING state, so we don't have anything to
57 // say. This will be set when the process is STARTING and STOPPING as well,
58 // because it may be in a transient state and we don't want to accidentally
59 // send out false positives regarding file changes.
60 NOT_RUNNING,
61
62 // The currently executing file is the one on disk.
63 NO_CHANGE,
64
65 // The file changed at some point between the fork() call and when we
66 // entered the RUNNING state, and we aren't currently set up to determine
67 // if the executed file is the one currently on disk.
68 CHANGED_DURING_STARTUP,
69
70 // The file has changed since it started RUNNING.
71 CHANGED,
72}
73
Tyler Chatowa79419d2020-08-12 20:12:11 -070074table Status {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080075 statuses: [ApplicationStatus] (id: 0);
Tyler Chatowa79419d2020-08-12 20:12:11 -070076}
77
78table ApplicationStatus {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080079 name: string (id: 0);
Tyler Chatowa79419d2020-08-12 20:12:11 -070080
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080081 state: State (id: 1);
Tyler Chatowa79419d2020-08-12 20:12:11 -070082
83 // Last exit code of the process. Has a value of 0 if not started.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080084 last_exit_code: ubyte (id: 2);
Tyler Chatowa79419d2020-08-12 20:12:11 -070085
86 // Last pid of the process. Could be associated with a different process
87 // unless status == RUNNING. Not present if the process has not started.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080088 pid: uint (id: 3);
Tyler Chatowa79419d2020-08-12 20:12:11 -070089
90 // Unique id of this application and process
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080091 id: uint64 (id: 4);
Tyler Chatowa79419d2020-08-12 20:12:11 -070092
93 // Start time in nanoseconds relative to monotonic clock
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080094 last_start_time: int64 (id: 5);
Tyler Chatowa79419d2020-08-12 20:12:11 -070095
96 // Indicates the reason the application is not running. Only valid if
97 // application is STOPPED.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080098 last_stop_reason: LastStopReason (id: 6);
James Kuszmaul6295a642022-03-22 15:23:59 -070099
100 // Debug information providing the approximate CPU usage and memory footprint of the process.
101 // Populated whenever the process is running (i.e., state != STOPPED). While STOPPING could
102 // refer to another process if another process has somehow claimed the application's PID between
103 // actually stopping and the parent process receiving the signal indicating that the application
104 // finished stopping.
105 process_info: util.ProcessInfo (id: 7);
James Kuszmaul8544c492023-07-31 15:00:38 -0700106
107 // Indicates whether we have observed a recent AOS timing report from
108 // the application. Staleness is calculated based on the timing report period
109 // specified for the starterd application (defaults to 1 Hz, can be overridden
110 // by --timing_report_ms).
111 has_active_timing_report: bool (id: 8);
James Kuszmaul37a56af2023-07-29 15:15:16 -0700112
113 // Current state of the running executable. This can be used to detect if
114 // a process should be restarted because the file has changed on disk.
115 file_state: FileState (id: 9);
Tyler Chatowa79419d2020-08-12 20:12:11 -0700116}
117
118root_type Status;