diff options
-rw-r--r-- | dmt/Dockerfile | 1 | ||||
-rwxr-xr-x | dmt/dmt | 36 |
2 files changed, 37 insertions, 0 deletions
diff --git a/dmt/Dockerfile b/dmt/Dockerfile index 6d53838..f440d5e 100644 --- a/dmt/Dockerfile +++ b/dmt/Dockerfile @@ -14,6 +14,7 @@ ENV GOPATH="/usr/local" COPY . . RUN go install github.com/uriel/cgd@latest +RUN tr -dc a-z </dev/urandom | head -c 12 >/version EXPOSE 80 CMD ["cgd", "-a", ":80", "-c", "dmt"] @@ -0,0 +1,36 @@ +#!/bin/bash -a + +# cychedelic DMT daemon +# cychedelic is an automated Continuous Deployment solution. See the README for +# more information. + +CYCHE_LOG_DIR="/data/logs" +CYCHE_STATUS_FILE="/data/status" +CYCHE_VERSION_FILE="/version" + +integer() { + [ "$1" -eq "$1" ] >/dev/null 2>&1 +} + +newest_job() { + ls -A "$CYCHE_LOG_DIR" | sort -rn | head -n1 +} + +oldest_job() { + ls -A "$CYCHE_LOG_DIR" | sort -n | head -n1 +} + +api_status() { + status=$(cat "$CYCHE_STATUS_FILE") + [ "$status" == "" ] && active="false" || active="true" + integer "$status" && job="$status" || job="-1" + + printf 'Content-type: text/json\n\n{' + printf '"version":"%s",' "$(cat "$CYCHE_VERSION_FILE")" + printf '"active":%s,' "$active" + printf '"job":%i,' "$job" + printf '"newest":%i,' "$(newest_job)" + printf '"oldest":%i}' "$(oldest_job)" +} + +api_status |