Skip to content
Snippets Groups Projects

Fix for mage run does not stop containers

Merged Pieter van Staden requested to merge 1-mage-run-does-not-stop-containers into main
1 file
+ 16
6
Compare changes
  • Side-by-side
  • Inline
+ 16
6
@@ -111,7 +111,7 @@ func runLongRunningSubProcess(ctx context.Context, name string, arg ...string) e
}
func stopRunningSamDocker() {
cli, err := client.NewEnvClient()
cli, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
panic(err)
}
@@ -122,14 +122,24 @@ func stopRunningSamDocker() {
}
for _, container := range containers {
for _, port := range container.Ports {
if port.PrivatePort == 5986 {
err = cli.ContainerStop(context.Background(), container.ID, nil)
if err != nil {
panic(err)
mustStop := false
if container.Command == "/var/rapid/aws-lambda-rie" {
mustStop = true
} else {
for _, port := range container.Ports {
if port.PrivatePort == 5986 {
mustStop = true
break
}
}
}
if mustStop {
err = cli.ContainerStop(context.Background(), container.ID, nil)
if err != nil {
panic(err)
}
log.Printf("Stopped container %s\n", container.ID)
}
}
}
Loading