mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 00:17:07 +08:00
Fix crash while stopping a process that is currently starting
This commit is contained in:
@@ -796,8 +796,18 @@ func (p *process) stop(wait bool, reason string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the process in starting state, wait until the process has been started
|
||||||
|
for {
|
||||||
|
if p.getState() == stateStarting {
|
||||||
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
// If the process is already in the finishing state, don't do anything
|
// If the process is already in the finishing state, don't do anything
|
||||||
if p.getState() == stateFinishing {
|
if state, _ := p.setState(stateFinishing); state == stateFinishing {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -805,8 +815,6 @@ func (p *process) stop(wait bool, reason string) error {
|
|||||||
p.stopReason = reason
|
p.stopReason = reason
|
||||||
p.stopReasonLock.Unlock()
|
p.stopReasonLock.Unlock()
|
||||||
|
|
||||||
p.setState(stateFinishing)
|
|
||||||
|
|
||||||
p.logger.Info().Log("Stopping")
|
p.logger.Info().Log("Stopping")
|
||||||
p.debuglogger.WithFields(log.Fields{
|
p.debuglogger.WithFields(log.Fields{
|
||||||
"state": p.getStateString(),
|
"state": p.getStateString(),
|
||||||
|
Reference in New Issue
Block a user