forked from FactomProject/factomd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runStates.go
36 lines (31 loc) · 902 Bytes
/
runStates.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package runstate
import "fmt"
type RunState int
const (
New RunState = 0 // State of a newly created Factomd object
Booting RunState = 1 // State when starting up the server
Running RunState = 2 // State when doing processing
Stopping RunState = 3 // State when shutdown has been called but not finished
Stopped RunState = 4 // State when shutdown has been completed
)
// IsTerminating returns true if factomd is terminated or in the process of terminating
func (runState RunState) IsTerminating() bool {
return runState > Stopping
}
// String returns the current run state as a string
func (runState RunState) String() string {
switch runState {
case New:
return "New"
case Booting:
return "Booting"
case Running:
return "Running"
case Stopping:
return "Stopping"
case Stopped:
return "Stopped"
default:
return fmt.Sprintf("Unknown state %d", int(runState))
}
}