fix: handle error cases in starting a new vector container
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
@@ -108,19 +109,28 @@ func CommandVectorStart(vectorImage string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if !common.ContainerExists(vectorContainerName) {
|
||||
return startVectorContainer(vectorImage)
|
||||
if common.ContainerExists(vectorContainerName) {
|
||||
if common.ContainerIsRunning(vectorContainerName) {
|
||||
common.LogVerbose("Vector container is running")
|
||||
return nil
|
||||
}
|
||||
|
||||
common.LogVerbose("Starting vector container")
|
||||
if !common.ContainerStart(vectorContainerName) {
|
||||
return errors.New("Unable to start vector container")
|
||||
}
|
||||
} else {
|
||||
if err := startVectorContainer(vectorImage); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if common.ContainerIsRunning(vectorContainerName) {
|
||||
common.LogVerbose("Container already running")
|
||||
return nil
|
||||
}
|
||||
|
||||
if !common.ContainerStart(vectorContainerName) {
|
||||
return errors.New("Unable to start vector container")
|
||||
common.LogVerbose("Waiting for 10 seconds")
|
||||
if err := common.ContainerWaitTilReady(vectorContainerName, 10*time.Second); err != nil {
|
||||
return errors.New("Vector container did not start properly, run logs:vector-logs for more details")
|
||||
}
|
||||
|
||||
common.LogVerbose("Vector container is running")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user