Progress: Begin implementing re-run, fixing related problems.
To properly operate as an init (and improve the controller execution functionality), programs and services need to re-run after exiting.
A good example of this is the agetty program, which should re-run on both success and failure.
I attempted to take a simple approach with this design.
Example:
rerun start success delay 1000 reset
rerun start failure delay 5000 max 100
A "rerun" is applied to each Rule Action "start", "stop", "freeze", etc...
Each Rule Action has either a "success" or a "failure" state.
Each state may specify a delay, max, and a reset.
The delay provides how long to wait before re-running.
The max represents the maximum number of times to perform the re-run (setting to 0 results in no maximum).
The reset designates that the opposite return result (either success or failure) will have its counter reset.
That is, in the above example if failure is triggered 50 times and then success is triggered, the failure counter will be 0 again due to the reset on success.
Not specifying "rerun" will disable re-running.
This implements another array structure and the code is changed to perform the processing of the settings at an earlier point.
The previous design is a quick and simple but required additional looping before each execution.
The code now does the processing in the existing loops to avoid needing to loop later.
This requires adding new variables to the structure increasing memory footprint there but also decreases memory footprint in the actions array (and results in smaller actions array).
The "with" and "pid_file" are updated in this way as well.
The "user" and "group" have not yet been updated and need to be.
The configuration and validation of "rerun" is implemented, but the re-run functionality needs to be written.
The error checking, handling, and exiting will need to be reviewed after this work is complete.