Faster GetEdgeAppServices by skipping ones that should not be running
parent
3bb6200b1c
commit
4bb343769f
|
@ -416,12 +416,24 @@ func GetEdgeAppServices(ID string) []EdgeAppService {
|
||||||
var edgeAppServices []EdgeAppService
|
var edgeAppServices []EdgeAppService
|
||||||
|
|
||||||
for _, serviceID := range serviceSlices {
|
for _, serviceID := range serviceSlices {
|
||||||
|
shouldBeRunning := false
|
||||||
|
isRunning := false
|
||||||
|
|
||||||
|
// Check if the service is marked as "runnable" with the .run lockfile in the app folder
|
||||||
|
_, err := os.Stat(utils.GetPath(utils.EdgeAppsPath) + ID + "/" + serviceID + runnableFilename)
|
||||||
|
if !os.IsNotExist(err) {
|
||||||
|
shouldBeRunning = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the service is actually running
|
||||||
|
if shouldBeRunning {
|
||||||
cmdArgs = []string{"-f", wsPath + "/docker-compose.yml", "exec", "-T", serviceID, "echo", "'Service Check'"}
|
cmdArgs = []string{"-f", wsPath + "/docker-compose.yml", "exec", "-T", serviceID, "echo", "'Service Check'"}
|
||||||
cmdResult := utils.Exec(wsPath, "docker-compose", cmdArgs)
|
cmdResult := utils.Exec(wsPath, "docker-compose", cmdArgs)
|
||||||
isRunning := false
|
|
||||||
if cmdResult != "" {
|
if cmdResult != "" {
|
||||||
isRunning = true
|
isRunning = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
edgeAppServices = append(edgeAppServices, EdgeAppService{ID: serviceID, IsRunning: isRunning})
|
edgeAppServices = append(edgeAppServices, EdgeAppService{ID: serviceID, IsRunning: isRunning})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue