Merge 'shutdown' and 'offline' states

Move the 'shutdown' state code to the 'offline' state, to match the
removal of the 'shutdown' state from the OpenAPI definition.
This commit is contained in:
Sybren A. Stüvel 2022-06-02 16:26:23 +02:00
parent cf8b4e18b1
commit 132ce8f2ec
3 changed files with 6 additions and 6 deletions

View File

@ -149,7 +149,7 @@ func (f *Flamenco) SignOff(e echo.Context) error {
w := requestWorkerOrPanic(e) w := requestWorkerOrPanic(e)
prevStatus := w.Status prevStatus := w.Status
w.Status = api.WorkerStatusOffline w.Status = api.WorkerStatusOffline
if w.StatusRequested == api.WorkerStatusShutdown { if w.StatusRequested == api.WorkerStatusOffline {
w.StatusRequested = "" w.StatusRequested = ""
} }

View File

@ -11,11 +11,11 @@ import (
"git.blender.org/flamenco/pkg/api" "git.blender.org/flamenco/pkg/api"
) )
func (w *Worker) gotoStateShutdown(context.Context) { func (w *Worker) gotoStateOffline(context.Context) {
w.stateMutex.Lock() w.stateMutex.Lock()
defer w.stateMutex.Unlock() defer w.stateMutex.Unlock()
w.state = api.WorkerStatusShutdown w.state = api.WorkerStatusOffline
logger := log.With().Int("pid", os.Getpid()).Logger() logger := log.With().Int("pid", os.Getpid()).Logger()
proc, err := os.FindProcess(os.Getpid()) proc, err := os.FindProcess(os.Getpid())
@ -26,7 +26,7 @@ func (w *Worker) gotoStateShutdown(context.Context) {
logger.Warn().Msg("sending our own process an interrupt signal") logger.Warn().Msg("sending our own process an interrupt signal")
err = proc.Signal(os.Interrupt) err = proc.Signal(os.Interrupt)
if err != nil { if err != nil {
logger.Fatal().Err(err).Msg("unable to find send interrupt signal to our own process") logger.Fatal().Err(err).Msg("unable to send interrupt signal to our own process")
} }
} }
@ -34,7 +34,7 @@ func (w *Worker) gotoStateShutdown(context.Context) {
// Does NOT actually peform a shutdown; is intended to be called while shutdown is in progress. // Does NOT actually peform a shutdown; is intended to be called while shutdown is in progress.
func (w *Worker) SignOff(ctx context.Context) { func (w *Worker) SignOff(ctx context.Context) {
w.stateMutex.Lock() w.stateMutex.Lock()
w.state = api.WorkerStatusShutdown w.state = api.WorkerStatusOffline
logger := log.With().Str("state", string(w.state)).Logger() logger := log.With().Str("state", string(w.state)).Logger()
w.stateMutex.Unlock() w.stateMutex.Unlock()

View File

@ -14,7 +14,7 @@ import (
func (w *Worker) setupStateMachine() { func (w *Worker) setupStateMachine() {
w.stateStarters[api.WorkerStatusAsleep] = w.gotoStateAsleep w.stateStarters[api.WorkerStatusAsleep] = w.gotoStateAsleep
w.stateStarters[api.WorkerStatusAwake] = w.gotoStateAwake w.stateStarters[api.WorkerStatusAwake] = w.gotoStateAwake
w.stateStarters[api.WorkerStatusShutdown] = w.gotoStateShutdown w.stateStarters[api.WorkerStatusOffline] = w.gotoStateOffline
} }
// Called whenever the Flamenco Manager has a change in current status for us. // Called whenever the Flamenco Manager has a change in current status for us.