fix: correctly handle is-deployed check
Previously, checking if an app was deployed actually checked if there were any running processes. This is not only incorrect, but also fails to take into account applications that do not have running processes and are only used for one-off commands. This fix migrates apps to the new "deployed" property which is set in core-post-deploy. The result is a slightly faster "deployed" check that is correct and allows non-scaled apps to actually work. Closes #4398
This commit is contained in:
34
plugins/common/src/common/common.go
Normal file
34
plugins/common/src/common/common.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
flag "github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
func main() {
|
||||
quiet := flag.Bool("quiet", false, "--quiet: set DOKKU_QUIET_OUTPUT=1")
|
||||
flag.Parse()
|
||||
cmd := flag.Arg(0)
|
||||
|
||||
if *quiet {
|
||||
os.Setenv("DOKKU_QUIET_OUTPUT", "1")
|
||||
}
|
||||
|
||||
var err error
|
||||
switch cmd {
|
||||
case "is-deployed":
|
||||
appName := flag.Arg(1)
|
||||
if !common.IsDeployed(appName) {
|
||||
err = fmt.Errorf("App %v not deployed", appName)
|
||||
}
|
||||
default:
|
||||
err = fmt.Errorf("Invalid common command call: %v", cmd)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
common.LogFailQuiet(err.Error())
|
||||
}
|
||||
}
|
||||
35
plugins/common/src/triggers/triggers.go
Normal file
35
plugins/common/src/triggers/triggers.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// main entrypoint to all triggers
|
||||
func main() {
|
||||
parts := strings.Split(os.Args[0], "/")
|
||||
trigger := parts[len(parts)-1]
|
||||
flag.Parse()
|
||||
|
||||
var err error
|
||||
switch trigger {
|
||||
case "core-post-deploy":
|
||||
appName := flag.Arg(0)
|
||||
err = common.TriggerCorePostDeploy(appName)
|
||||
case "install":
|
||||
err = common.TriggerInstall()
|
||||
case "post-delete":
|
||||
appName := flag.Arg(0)
|
||||
err = common.TriggerPostDelete(appName)
|
||||
default:
|
||||
common.LogFail(fmt.Sprintf("Invalid plugin trigger call: %s", trigger))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
common.LogFail(err.Error())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user