@@ -112,7 +112,7 @@ to interact and monitor the Scroll Application`,
112112
113113 portService := services .NewPortServiceWithScrollFile (scrollService .GetFile ())
114114
115- coldStarter := services .NewColdStarter (scrollService .GetDir (), portService )
115+ coldStarter := services .NewColdStarter (portService , queueManager , scrollService .GetDir ())
116116
117117 scrollHandler := handler .NewScrollHandler (scrollService , pluginManager , processLauncher , queueManager )
118118 processHandler := handler .NewProcessHandler (processManager )
@@ -165,18 +165,13 @@ to interact and monitor the Scroll Application`,
165165 finish := coldStarter .Start (ctx )
166166 executedPort := <- finish
167167
168- if executedPort != nil && executedPort .StartDelay > 0 {
169- go func () {
170- time .Sleep (time .Duration (executedPort .StartDelay ) * time .Second )
171- coldStarter .Stop ()
172- }()
173- } else {
174- coldStarter .Stop ()
168+ if executedPort .FinishAfterCommand == "" {
169+ coldStarter .Stop (executedPort .StartDelay )
175170 }
176171
177172 logger .Log ().Info ("Coldstarter done, starting scroll" )
178173
179- startup (scrollService , processLauncher , queueManager , cwd , doneChan )
174+ startup (scrollService , processLauncher , queueManager , portService , coldStarter , cwd , doneChan )
180175
181176 portService .ResetOpenPorts ()
182177
@@ -216,10 +211,10 @@ to interact and monitor the Scroll Application`,
216211 }
217212 } else {
218213 logger .Log ().Warn ("No ports to start, skipping coldstarter" )
219- startup (scrollService , processLauncher , queueManager , cwd , doneChan )
214+ startup (scrollService , processLauncher , queueManager , portService , coldStarter , cwd , doneChan )
220215 }
221216 } else {
222- startup (scrollService , processLauncher , queueManager , cwd , doneChan )
217+ startup (scrollService , processLauncher , queueManager , portService , coldStarter , cwd , doneChan )
223218 }
224219
225220 }()
@@ -269,7 +264,7 @@ func init() {
269264 ServeCommand .Flags ().UintVarP (& maxStartupHealthCheckTimeout , "max-health-check-startup-timeount" , "" , 0 , "Sets the max amount of time the health check is allowed to take on startup. If the value is 0, there will be no timeout. This is useful to prevent the health check from blocking the startup of the daemon fully." )
270265}
271266
272- func startup (scrollService * services.ScrollService , processLauncher * services.ProcedureLauncher , queueManager * services.QueueManager , cwd string , doneChan chan error ) {
267+ func startup (scrollService * services.ScrollService , processLauncher * services.ProcedureLauncher , queueManager * services.QueueManager , portSerivce * services. PortMonitor , coldStarter * services. ColdStarter , cwd string , doneChan chan error ) {
273268
274269 currentScroll := scrollService .GetCurrent ()
275270
@@ -330,7 +325,17 @@ func startup(scrollService *services.ScrollService, processLauncher *services.Pr
330325 logger .Log ().Info ("Bootstrapping done" )
331326 }
332327
333- err = queueManager .QueueLockFile ()
328+ callbacks := map [string ]func (){}
329+
330+ for _ , port := range portSerivce .GetPorts () {
331+ if port .FinishAfterCommand != "" {
332+ callbacks [port .FinishAfterCommand ] = func () {
333+ coldStarter .Stop (port .StartDelay )
334+ }
335+ }
336+ }
337+
338+ err = queueManager .QueueLockFile (callbacks )
334339 if err != nil {
335340 doneChan <- err
336341 return
0 commit comments