Merge pull request #3574 from dokku/scheduler-app-status

Add support for pulling app status from scheduler plugins
This commit is contained in:
Jose Diaz-Gonzalez
2019-05-28 14:54:04 -04:00
committed by GitHub
2 changed files with 40 additions and 20 deletions

View File

@@ -222,27 +222,9 @@ get_restart_policies() {
fn-ps-app-status() {
declare APP="$1"
local PROCS=0 RUNNING=""
local APP_CIDS=$(get_app_container_ids "$APP")
for CID in $APP_CIDS; do
if (is_container_status "$CID" "Running"); then
RUNNING+="0"
else
RUNNING+="1"
fi
PROCS=$((PROCS + 1))
done
if [[ "${#RUNNING}" -eq 0 ]] || [[ "${#RUNNING}" -ne 0 ]] && [[ "$RUNNING" != *"0"* ]]; then
RUNNING="false"
elif [[ "$RUNNING" != *"1"* ]] && [[ "${#RUNNING}" -ne 0 ]]; then
RUNNING="true"
else
RUNNING="mixed"
fi
echo "$PROCS $RUNNING"
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
plugn trigger scheduler-app-status "$DOKKU_SCHEDULER" "$APP"
}
fn-ps-is-app-running() {

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
scheduler-app-status() {
declare desc="fetches the status for a given app"
declare trigger="scheduler-docker-local scheduler-app-status"
declare DOKKU_SCHEDULER="$1" APP="$2"
if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then
return
fi
local PROCS=0 RUNNING=""
local APP_CIDS=$(get_app_container_ids "$APP")
for CID in $APP_CIDS; do
if (is_container_status "$CID" "Running"); then
RUNNING+="0"
else
RUNNING+="1"
fi
PROCS=$((PROCS + 1))
done
if [[ "${#RUNNING}" -eq 0 ]] || [[ "${#RUNNING}" -ne 0 ]] && [[ "$RUNNING" != *"0"* ]]; then
RUNNING="false"
elif [[ "$RUNNING" != *"1"* ]] && [[ "${#RUNNING}" -ne 0 ]]; then
RUNNING="true"
else
RUNNING="mixed"
fi
echo "$PROCS $RUNNING"
}
scheduler-app-status "$@"