change service#Stop to be similar to Start
This commit is contained in:
parent
4123d54bf6
commit
e6164d4052
|
@ -16,7 +16,7 @@ type Service interface {
|
||||||
Start() error
|
Start() error
|
||||||
OnStart() error
|
OnStart() error
|
||||||
|
|
||||||
Stop() bool
|
Stop() error
|
||||||
OnStop()
|
OnStop()
|
||||||
|
|
||||||
Reset() (bool, error)
|
Reset() (bool, error)
|
||||||
|
@ -127,15 +127,15 @@ func (bs *BaseService) Start() error {
|
||||||
func (bs *BaseService) OnStart() error { return nil }
|
func (bs *BaseService) OnStart() error { return nil }
|
||||||
|
|
||||||
// Implements Service
|
// Implements Service
|
||||||
func (bs *BaseService) Stop() bool {
|
func (bs *BaseService) Stop() error {
|
||||||
if atomic.CompareAndSwapUint32(&bs.stopped, 0, 1) {
|
if atomic.CompareAndSwapUint32(&bs.stopped, 0, 1) {
|
||||||
bs.Logger.Info(Fmt("Stopping %v", bs.name), "impl", bs.impl)
|
bs.Logger.Info(Fmt("Stopping %v", bs.name), "impl", bs.impl)
|
||||||
bs.impl.OnStop()
|
bs.impl.OnStop()
|
||||||
close(bs.Quit)
|
close(bs.Quit)
|
||||||
return true
|
return nil
|
||||||
} else {
|
} else {
|
||||||
bs.Logger.Debug(Fmt("Stopping %v (ignoring: already stopped)", bs.name), "impl", bs.impl)
|
bs.Logger.Debug(Fmt("Stopping %v (ignoring: already stopped)", bs.name), "impl", bs.impl)
|
||||||
return false
|
return ErrAlreadyStopped
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue