Handle all process terminations.
This commit is contained in:
parent
716ff7e372
commit
f788724881
1 changed files with 21 additions and 10 deletions
|
|
@ -99,11 +99,9 @@ import org.jgrapes.util.events.WatchFile;
|
||||||
* which --> qemu: [else]
|
* which --> qemu: [else]
|
||||||
*
|
*
|
||||||
* swtpm: entry/start swtpm
|
* swtpm: entry/start swtpm
|
||||||
* swtpm -> error: StartProcessError/stop
|
|
||||||
* swtpm -> qemu: FileChanged[swtpm socket created]
|
* swtpm -> qemu: FileChanged[swtpm socket created]
|
||||||
*
|
*
|
||||||
* qemu: entry/start qemu
|
* qemu: entry/start qemu
|
||||||
* qemu -> error: StartProcessError/stop
|
|
||||||
* qemu --> monitor : FileChanged[monitor socket created]
|
* qemu --> monitor : FileChanged[monitor socket created]
|
||||||
*
|
*
|
||||||
* monitor: entry/fire OpenSocketConnection
|
* monitor: entry/fire OpenSocketConnection
|
||||||
|
|
@ -114,25 +112,30 @@ import org.jgrapes.util.events.WatchFile;
|
||||||
* Initializing --> which: Started
|
* Initializing --> which: Started
|
||||||
*
|
*
|
||||||
* success --> Running
|
* success --> Running
|
||||||
* error --> [*]
|
|
||||||
*
|
*
|
||||||
* state Terminating {
|
* state Terminating {
|
||||||
|
* state terminate <<entryPoint>>
|
||||||
|
* state qemuRunning <<choice>>
|
||||||
* state terminated <<exitPoint>>
|
* state terminated <<exitPoint>>
|
||||||
* state which2 <<choice>>
|
|
||||||
*
|
|
||||||
* state "Powerdown qemu" as qemuPowerdown
|
* state "Powerdown qemu" as qemuPowerdown
|
||||||
* state "Await process termination" as terminateProcesses
|
* state "Await process termination" as terminateProcesses
|
||||||
|
*
|
||||||
|
* terminate --> qemuRunning
|
||||||
|
* qemuRunning --> qemuPowerdown:[qemu monitor open]
|
||||||
|
* qemuRunning --> terminateProcesses:[else]
|
||||||
|
*
|
||||||
* qemuPowerdown: entry/suspend Stop, send powerdown to qemu, start timer
|
* qemuPowerdown: entry/suspend Stop, send powerdown to qemu, start timer
|
||||||
*
|
*
|
||||||
* qemuPowerdown --> which2: Closed[for monitor]/resume Stop
|
* qemuPowerdown --> terminateProcesses: Closed[for monitor]/resume Stop
|
||||||
* qemuPowerdown --> terminateProcesses: Timeout/resume Stop
|
* qemuPowerdown --> terminateProcesses: Timeout/resume Stop
|
||||||
* which2 --> terminateProcesses: [use swtmp]
|
|
||||||
* which2 --> terminated: [else]
|
|
||||||
* terminateProcesses --> terminated
|
* terminateProcesses --> terminated
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Running --> qemuPowerdown: Stop
|
* Running --> terminate: Stop
|
||||||
* Running --> which2: ProcessExited[process qemu]
|
* Running --> terminate: ProcessExited[process qemu]
|
||||||
|
* error --> terminate
|
||||||
|
* StartingProcess --> terminate: ProcessExited
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* terminated --> [*]
|
* terminated --> [*]
|
||||||
*
|
*
|
||||||
|
|
@ -449,6 +452,14 @@ public class Runner extends Component {
|
||||||
@Handler
|
@Handler
|
||||||
public void onProcessExited(ProcessExited event, ProcessChannel channel) {
|
public void onProcessExited(ProcessExited event, ProcessChannel channel) {
|
||||||
channel.associated(CommandDefinition.class).ifPresent(procDef -> {
|
channel.associated(CommandDefinition.class).ifPresent(procDef -> {
|
||||||
|
// No process(es) may exit during startup
|
||||||
|
if (state.get() == State.STARTING) {
|
||||||
|
logger.severe(() -> "Process " + procDef.name
|
||||||
|
+ " has exited with value " + event.exitValue()
|
||||||
|
+ " during startup.");
|
||||||
|
fire(new Stop());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (procDef.equals(qemuDefinition)
|
if (procDef.equals(qemuDefinition)
|
||||||
&& state.get() == State.RUNNING) {
|
&& state.get() == State.RUNNING) {
|
||||||
fire(new Stop());
|
fire(new Stop());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue