feat: implement all of ps:report
This commit is contained in:
1 parent
bb9f764b9f
commit
e8d0965a33
2 files changed
+39
No files matched your search
@@ -152,6 +152,13 @@ func getRestartPolicy(appName string) (string, error) {
|
|||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getProcessCount(appName string) (int, error) {
|
||||||
|
scheduler := common.GetAppScheduler(appName)
|
||||||
|
b, _ := common.PlugnTriggerOutput("scheduler-app-status", []string{scheduler, appName}...)
|
||||||
|
count := strings.Split(strings.TrimSpace(string(b[:])), " ")[0]
|
||||||
|
return strconv.Atoi(count)
|
||||||
|
}
|
||||||
|
|
||||||
func getRunningState(appName string) string {
|
func getRunningState(appName string) string {
|
||||||
scheduler := common.GetAppScheduler(appName)
|
scheduler := common.GetAppScheduler(appName)
|
||||||
b, _ := common.PlugnTriggerOutput("scheduler-app-status", []string{scheduler, appName}...)
|
b, _ := common.PlugnTriggerOutput("scheduler-app-status", []string{scheduler, appName}...)
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package ps
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/dokku/dokku/plugins/common"
|
"github.com/dokku/dokku/plugins/common"
|
||||||
)
|
)
|
||||||
@@ -72,7 +74,37 @@ func ReportSingleApp(appName, infoFlag string) error {
|
|||||||
policy = DefaultProperties["restart-policy"]
|
policy = DefaultProperties["restart-policy"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canScale := "false"
|
||||||
|
if canScaleApp(appName) {
|
||||||
|
canScale = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
deployed := "false"
|
||||||
|
if common.IsDeployed(appName) {
|
||||||
|
deployed = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
runningState := getRunningState(appName)
|
||||||
|
|
||||||
|
count, err := getProcessCount(appName)
|
||||||
|
if err != nil {
|
||||||
|
count = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
b, _ := common.PlugnTriggerOutput("config-get", []string{appName, "DOKKU_APP_RESTORE"}...)
|
||||||
|
restore := strings.TrimSpace(string(b[:]))
|
||||||
|
if restore == "0" {
|
||||||
|
restore = "false"
|
||||||
|
} else {
|
||||||
|
restore = "true"
|
||||||
|
}
|
||||||
|
|
||||||
infoFlags := map[string]string{
|
infoFlags := map[string]string{
|
||||||
|
"--processes": strconv.Itoa(count),
|
||||||
|
"--running": runningState,
|
||||||
|
"--restore": restore,
|
||||||
|
"--deployed": deployed,
|
||||||
|
"--ps-can-scale": canScale,
|
||||||
"--ps-restart-policy": policy,
|
"--ps-restart-policy": policy,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user