@@ -81,12 +81,6 @@ func main() {
81
81
82
82
runner := runners .NewLocalRunner (cfg .Provision .UseSudo )
83
83
84
- pm := pool .NewPoolManager (& cfg .PoolManager , runner )
85
- if err = pm .ReloadPools (); err != nil {
86
- log .Err (err .Error ())
87
- return
88
- }
89
-
90
84
internalNetworkID , err := networks .Setup (ctx , docker , engProps .InstanceID , engProps .ContainerName )
91
85
if err != nil {
92
86
log .Errf (err .Error ())
@@ -107,21 +101,17 @@ func main() {
107
101
DBName : cfg .Global .Database .Name (),
108
102
}
109
103
110
- emergencyShutdown := func () {
111
- cancel ()
112
-
113
- shutdownCtx , shutdownCancel := context .WithTimeout (context .Background (), shutdownTimeout )
114
- defer shutdownCancel ()
115
-
116
- shutdownDatabaseLabEngine (shutdownCtx , docker , engProps , pm .First ().Pool ())
117
- }
118
-
119
104
tm , err := telemetry .New (cfg .Global , engProps )
120
105
if err != nil {
121
106
log .Errf (errors .WithMessage (err , "failed to initialize a telemetry service" ).Error ())
122
107
return
123
108
}
124
109
110
+ pm := pool .NewPoolManager (& cfg .PoolManager , runner )
111
+ if err = pm .ReloadPools (); err != nil {
112
+ log .Err (err .Error ())
113
+ }
114
+
125
115
// Create a new retrieval service to prepare a data directory and start snapshotting.
126
116
retrievalSvc := retrieval .New (cfg , engProps , docker , pm , tm , runner )
127
117
@@ -133,6 +123,15 @@ func main() {
133
123
134
124
observingChan := make (chan string , 1 )
135
125
126
+ emergencyShutdown := func () {
127
+ cancel ()
128
+
129
+ shutdownCtx , shutdownCancel := context .WithTimeout (context .Background (), shutdownTimeout )
130
+ defer shutdownCancel ()
131
+
132
+ shutdownDatabaseLabEngine (shutdownCtx , docker , engProps , pm .First ())
133
+ }
134
+
136
135
cloningSvc := cloning .NewBase (& cfg .Cloning , provisioner , tm , observingChan )
137
136
if err = cloningSvc .Run (ctx ); err != nil {
138
137
log .Err (err )
@@ -193,7 +192,7 @@ func main() {
193
192
log .Msg (err )
194
193
}
195
194
196
- shutdownDatabaseLabEngine (shutdownCtx , docker , engProps , pm .First (). Pool () )
195
+ shutdownDatabaseLabEngine (shutdownCtx , docker , engProps , pm .First ())
197
196
cloningSvc .SaveClonesState ()
198
197
tm .SendEvent (context .Background (), telemetry .EngineStoppedEvent , telemetry.EngineStopped {Uptime : server .Uptime ()})
199
198
}
@@ -292,11 +291,13 @@ func setShutdownListener() chan os.Signal {
292
291
return c
293
292
}
294
293
295
- func shutdownDatabaseLabEngine (ctx context.Context , dockerCLI * client.Client , engProps global.EngineProps , fsp * resources. Pool ) {
294
+ func shutdownDatabaseLabEngine (ctx context.Context , dockerCLI * client.Client , engProps global.EngineProps , fsm pool. FSManager ) {
296
295
log .Msg ("Stopping auxiliary containers" )
297
296
298
- if err := cont .StopControlContainers (ctx , dockerCLI , engProps .InstanceID , fsp .DataDir ()); err != nil {
299
- log .Err ("Failed to stop control containers" , err )
297
+ if fsm != nil {
298
+ if err := cont .StopControlContainers (ctx , dockerCLI , engProps .InstanceID , fsm .Pool ().DataDir ()); err != nil {
299
+ log .Err ("Failed to stop control containers" , err )
300
+ }
300
301
}
301
302
302
303
if err := cont .CleanUpSatelliteContainers (ctx , dockerCLI , engProps .InstanceID ); err != nil {
0 commit comments