feat: implement all of ps:report
This commit is contained in:
@@ -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}...)
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user