forked from TrueCloudLab/frostfs-node
WIP: Morph: Add unit tests #2
2 changed files with 6 additions and 5 deletions
|
@ -321,6 +321,7 @@ func (a *applicationConfiguration) setGCConfig(newConfig *shardCfg, oldConfig *s
|
||||||
// helpers and fields.
|
// helpers and fields.
|
||||||
type internals struct {
|
type internals struct {
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
|
ctxCancel func()
|
||||||
internalErr chan error // channel for internal application errors at runtime
|
internalErr chan error // channel for internal application errors at runtime
|
||||||
|
|
||||||
appCfg *config.Config
|
appCfg *config.Config
|
||||||
|
@ -1078,6 +1079,7 @@ func (c *cfg) reloadConfig(ctx context.Context) {
|
||||||
func (c *cfg) shutdown() {
|
func (c *cfg) shutdown() {
|
||||||
c.setHealthStatus(control.HealthStatus_SHUTTING_DOWN)
|
c.setHealthStatus(control.HealthStatus_SHUTTING_DOWN)
|
||||||
|
|
||||||
|
c.ctxCancel()
|
||||||
c.done <- struct{}{}
|
c.done <- struct{}{}
|
||||||
for i := range c.closers {
|
for i := range c.closers {
|
||||||
c.closers[len(c.closers)-1-i].fn()
|
c.closers[len(c.closers)-1-i].fn()
|
||||||
|
|
|
@ -57,7 +57,8 @@ func main() {
|
||||||
|
|
||||||
c := initCfg(appCfg)
|
c := initCfg(appCfg)
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
var ctx context.Context
|
||||||
|
ctx, c.ctxCancel = context.WithCancel(context.Background())
|
||||||
|
|
||||||
initApp(ctx, c)
|
initApp(ctx, c)
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ func main() {
|
||||||
|
|
||||||
c.setHealthStatus(control.HealthStatus_READY)
|
c.setHealthStatus(control.HealthStatus_READY)
|
||||||
|
|
||||||
wait(c, cancel)
|
wait(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initAndLog(c *cfg, name string, initializer func(*cfg)) {
|
func initAndLog(c *cfg, name string, initializer func(*cfg)) {
|
||||||
|
@ -140,14 +141,12 @@ func bootUp(ctx context.Context, c *cfg) {
|
||||||
startWorkers(ctx, c)
|
startWorkers(ctx, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func wait(c *cfg, cancel func()) {
|
func wait(c *cfg) {
|
||||||
c.log.Info(logs.CommonApplicationStarted,
|
c.log.Info(logs.CommonApplicationStarted,
|
||||||
zap.String("version", misc.Version))
|
zap.String("version", misc.Version))
|
||||||
|
|
||||||
<-c.done // graceful shutdown
|
<-c.done // graceful shutdown
|
||||||
|
|
||||||
cancel()
|
|
||||||
|
|
||||||
c.log.Debug(logs.FrostFSNodeWaitingForAllProcessesToStop)
|
c.log.Debug(logs.FrostFSNodeWaitingForAllProcessesToStop)
|
||||||
|
|
||||||
c.wg.Wait()
|
c.wg.Wait()
|
||||||
|
|
Loading…
Reference in a new issue