@@ -34,7 +34,7 @@ loopModels:
3434 if models [k ].Type != h .ModelType () {
3535 continue
3636 }
37- if h .NeedRegistration (ctx , & models [k ]) || models [k ].CheckRegistration {
37+ if h .CanSpawn ( ctx , & models [ k ], 0 , nil ) && ( h . NeedRegistration (ctx , & models [k ]) || models [k ].CheckRegistration ) {
3838 log .Debug ("hatchery> workerRegister> need register" )
3939 } else {
4040 continue
@@ -68,15 +68,13 @@ loopModels:
6868 continue
6969 }
7070
71- if h .NeedRegistration (ctx , & models [k ]) || models [k ].CheckRegistration {
72- if err := h .CDSClient ().WorkerModelBook (models [k ].Group .Name , models [k ].Name ); err != nil {
73- log .Debug ("%v" , sdk .WrapError (err , "cannot book model %s with id %d" , models [k ].Name , models [k ].ID ))
74- } else {
75- log .Info (ctx , "hatchery> workerRegister> spawning model %s (%d)" , models [k ].Name , models [k ].ID )
76- //Ask for the creation
77- startWorkerChan <- workerStarterRequest {
78- registerWorkerModel : & models [k ],
79- }
71+ if err := h .CDSClient ().WorkerModelBook (models [k ].Group .Name , models [k ].Name ); err != nil {
72+ log .Debug ("%v" , sdk .WrapError (err , "cannot book model %s with id %d" , models [k ].Name , models [k ].ID ))
73+ } else {
74+ log .Info (ctx , "hatchery> workerRegister> spawning model %s (%d)" , models [k ].Name , models [k ].ID )
75+ //Ask for the creation
76+ startWorkerChan <- workerStarterRequest {
77+ registerWorkerModel : & models [k ],
8078 }
8179 }
8280 }
0 commit comments