feat: implement all of ps:report

This commit is contained in:
Jose Diaz-Gonzalez
2020-11-17 03:28:26 -05:00
parent bb9f764b9f
commit e8d0965a33
2 changed files with 39 additions and 0 deletions

View File

@@ -152,6 +152,13 @@ func getRestartPolicy(appName string) (string, error) {
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 {
scheduler := common.GetAppScheduler(appName)
b, _ := common.PlugnTriggerOutput("scheduler-app-status", []string{scheduler, appName}...)

View File

@@ -2,6 +2,8 @@ package ps
import (
"fmt"
"strconv"
"strings"
"github.com/dokku/dokku/plugins/common"
)
@@ -72,7 +74,37 @@ func ReportSingleApp(appName, infoFlag string) error {
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{
"--processes": strconv.Itoa(count),
"--running": runningState,
"--restore": restore,
"--deployed": deployed,
"--ps-can-scale": canScale,
"--ps-restart-policy": policy,
}