Skip to content

Commit

Permalink
Added override flag to manager util (#135)
Browse files Browse the repository at this point in the history
* Added override flag to manager util

* Bumped version to 0.6.7
  • Loading branch information
Michael-Burke authored May 21, 2024
1 parent 1f33d36 commit a318650
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.6.6
current_version = 0.6.7

commit = True
tag = True
Expand Down
96 changes: 50 additions & 46 deletions src/_manage_postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,64 +145,68 @@ function mod_autofix() {
}

function mod_check_etl_status() {
local migration_exited="running"
title "Checking Data Migration Status"
info "Checking Migration Status"
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
local migration_exited=$(podman container inspect --format '{{.State.Status}}' "migrations")
else
local migration_exited=$(docker inspect --format '{{.State.Status}}' "plextrac-couchbase-migrations-1")
fi
while [ "$migration_exited" == "running" ]; do
# Check if the migration container has exited, e.g., migrations have completed or failed
if [ "${IGNORE_ETL_STATUS:-false}" == "false" ]; then
local migration_exited="running"
title "Checking Data Migration Status"
info "Checking Migration Status"
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
local migration_exited=$(podman container inspect --format '{{.State.Status}}' "migrations")
else
local migration_exited=$(docker inspect --format '{{.State.Status}}' "plextrac-couchbase-migrations-1")
fi
for s in / - \\ \|; do printf "\r$s"; sleep .1; done
done
printf "\r"
info "Migrations complete"
while [ "$migration_exited" == "running" ]; do
# Check if the migration container has exited, e.g., migrations have completed or failed
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
local migration_exited=$(podman container inspect --format '{{.State.Status}}' "migrations")
else
local migration_exited=$(docker inspect --format '{{.State.Status}}' "plextrac-couchbase-migrations-1")
fi
for s in / - \\ \|; do printf "\r$s"; sleep .1; done
done
printf "\r"
info "Migrations complete"

title "Checking Data ETL Status"
debug "Checking ETL health and status..."
ETL_OUTPUT=${ETL_OUTPUT:-true}
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
local api_running=$(podman container inspect --format '{{.State.Status}}' "plextracapi" | wc -l)
else
local api_running=$(compose_client ps -q plextracapi | wc -l)
fi
if [ $api_running -gt 0 ]; then
title "Checking Data ETL Status"
debug "Checking ETL health and status..."
ETL_OUTPUT=${ETL_OUTPUT:-true}
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
RAW_OUTPUT=$(podman exec plextracapi npm run pg:etl:status --no-update-notifier --if-present)
local api_running=$(podman container inspect --format '{{.State.Status}}' "plextracapi" | wc -l)
else
RAW_OUTPUT=$(compose_client exec plextracapi npm run pg:etl:status --no-update-notifier --if-present)
fi
if [ "$RAW_OUTPUT" == "" ]; then
debug "No ETL status output found or it failed to run."
return
local api_running=$(compose_client ps -q plextracapi | wc -l)
fi
# Find the json content by looking for the first line that starts
# with an opening brace and the first line that starts with a closing brace.
JSON_OUTPUT=$(echo "$RAW_OUTPUT" | sed '/^{/,/^}/!d')

# Find the summary content by finding the first line that starts
# with a closing brace and selecting all remaining lines after that one.
SUMMARY_OUTPUT=$(echo "$RAW_OUTPUT" | sed '1,/^}/d')
ETLS_COMBINED_STATUS=$(echo $JSON_OUTPUT | jq -r .etlsCombinedStatus)
if [ "${ETL_OUTPUT:-true}" == "true" ]; then
msg "$SUMMARY_OUTPUT\n"
debug "$JSON_OUTPUT\n"
fi

if [[ "$ETLS_COMBINED_STATUS" == "HEALTHY" ]]; then
info "All ETLs are in a healthy status."
if [ $api_running -gt 0 ]; then
if [ "$CONTAINER_RUNTIME" == "podman" ]; then
RAW_OUTPUT=$(podman exec plextracapi npm run pg:etl:status --no-update-notifier --if-present)
else
etl_failure
RAW_OUTPUT=$(compose_client exec plextracapi npm run pg:etl:status --no-update-notifier --if-present)
fi
if [ "$RAW_OUTPUT" == "" ]; then
debug "No ETL status output found or it failed to run."
return
fi
# Find the json content by looking for the first line that starts
# with an opening brace and the first line that starts with a closing brace.
JSON_OUTPUT=$(echo "$RAW_OUTPUT" | sed '/^{/,/^}/!d')

# Find the summary content by finding the first line that starts
# with a closing brace and selecting all remaining lines after that one.
SUMMARY_OUTPUT=$(echo "$RAW_OUTPUT" | sed '1,/^}/d')
ETLS_COMBINED_STATUS=$(echo $JSON_OUTPUT | jq -r .etlsCombinedStatus)
if [ "${ETL_OUTPUT:-true}" == "true" ]; then
msg "$SUMMARY_OUTPUT\n"
debug "$JSON_OUTPUT\n"
fi

if [[ "$ETLS_COMBINED_STATUS" == "HEALTHY" ]]; then
info "All ETLs are in a healthy status."
else
etl_failure
fi
else
info "PlexTrac API container not running, skipping ETL status check"
fi
else
info "PlexTrac API container not running, skipping ETL status check"
error "Skipping ETL status check"
fi
}

Expand Down
2 changes: 1 addition & 1 deletion src/plextrac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -Eeuo pipefail

VERSION=0.6.6
VERSION=0.6.7

## Podman Global Declaration Variable
declare -A svcValues
Expand Down

0 comments on commit a318650

Please sign in to comment.