mirror of
https://github.com/Graylog2/graylog2-server.git
synced 2026-03-13 09:32:21 +08:00
Delay opensearch start till configuration is available (#15615)
* Delay opensearch start till configuration is available * code cleanup
This commit is contained in:
@@ -20,7 +20,7 @@ public enum ProcessState {
|
||||
/**
|
||||
* Fresh created process, not started yet
|
||||
*/
|
||||
NEW,
|
||||
WAITING_FOR_CONFIGURATION,
|
||||
/**
|
||||
* The process is running on the underlying OS and has a process ID. It's not responding to the REST API yet
|
||||
*/
|
||||
|
||||
@@ -37,10 +37,10 @@ public class ProcessStateMachine {
|
||||
StateMachineConfig<ProcessState, ProcessEvent> config = new StateMachineConfig<>();
|
||||
|
||||
// Freshly created process, it hasn't started yet and doesn't have any pid.
|
||||
config.configure(ProcessState.NEW)
|
||||
config.configure(ProcessState.WAITING_FOR_CONFIGURATION)
|
||||
.permit(ProcessEvent.PROCESS_STARTED, ProcessState.STARTING)
|
||||
.permit(ProcessEvent.PROCESS_TERMINATED, ProcessState.TERMINATED)
|
||||
.permit(ProcessEvent.HEALTH_CHECK_FAILED, ProcessState.TERMINATED);
|
||||
.ignore(ProcessEvent.HEALTH_CHECK_FAILED);
|
||||
|
||||
// the process has started already, now we have to wait for a running OS and available REST api
|
||||
// the startupFailuresCounter keeps track of failed REST status calls and allow failures during the
|
||||
@@ -58,7 +58,8 @@ public class ProcessStateMachine {
|
||||
.onEntry(rebootCounter::resetFailuresCounter)
|
||||
.permitReentry(ProcessEvent.HEALTH_CHECK_OK)
|
||||
.permit(ProcessEvent.HEALTH_CHECK_FAILED, ProcessState.NOT_RESPONDING)
|
||||
.permit(ProcessEvent.PROCESS_TERMINATED, ProcessState.TERMINATED);
|
||||
.permit(ProcessEvent.PROCESS_TERMINATED, ProcessState.TERMINATED)
|
||||
.ignore(ProcessEvent.PROCESS_STARTED);
|
||||
|
||||
// if the REST api is not responding, we'll jump to this state and count how many times the failure
|
||||
// occurs. If it fails ttoo many times, we'll mark the process as FAILED
|
||||
@@ -83,6 +84,6 @@ public class ProcessStateMachine {
|
||||
.ignore(ProcessEvent.HEALTH_CHECK_FAILED)
|
||||
.ignore(ProcessEvent.PROCESS_TERMINATED); // final state, all following terminate events are ignored
|
||||
|
||||
return new StateMachine<>(ProcessState.NEW, config);
|
||||
return new StateMachine<>(ProcessState.WAITING_FOR_CONFIGURATION, config);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user