Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node details overrides + logging utils #415

Merged
merged 44 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9c67f68
node details overrides + logging utils
fmigneault Dec 15, 2023
4a5ed09
remove old config
fmigneault Dec 15, 2023
adda409
update changes
fmigneault Dec 15, 2023
6be39d8
update unittests with new birdhouse/scripts/read-configs.include.sh path
fmigneault Dec 15, 2023
805e5da
adjust cd exit 1 code
fmigneault Dec 15, 2023
816292b
replace all THIS_FILE with readlink|realpath cmd
fmigneault Dec 15, 2023
a41dd91
replace backticks by $(...) for path resolution operations
fmigneault Dec 19, 2023
d9fb457
fix canarie-api config conflict
fmigneault Dec 19, 2023
eff7dd3
update changes
fmigneault Jan 8, 2024
1d30103
add log function and logging level support
fmigneault Jan 8, 2024
6a75a10
add security defaults check for required variables that should be mod…
fmigneault Jan 11, 2024
8692201
add note about deprecated vars defaults
fmigneault Jan 12, 2024
c92e6a0
jupyterhub: ensure username variables are respected everywhere
mishaschwartz Jan 16, 2024
92c3fab
Merge branch 'master' into fix-node-details
fmigneault Jan 19, 2024
4fd9d01
ensure change is backwards compatible
mishaschwartz Jan 22, 2024
7390245
unittest
mishaschwartz Jan 22, 2024
7ea0f63
adjust sourced config file to standardize across scripts
fmigneault Jan 23, 2024
2d120a1
remove duplicate nested include of logging utils
fmigneault Jan 23, 2024
7314005
adjust pre/post compose script to include -x command display only on …
fmigneault Jan 23, 2024
17c5a94
add double quotes around default values
fmigneault Jan 23, 2024
ec77c07
Merge branch 'fix-node-details' of https://github.com/bird-house/bird…
fmigneault Jan 23, 2024
88e8ab3
Merge branch 'master' into fix-node-details
fmigneault Jan 23, 2024
58b2c4c
revert canarie config invalid template vars values
fmigneault Jan 23, 2024
1c8b615
Merge branch 'fix-node-details' into security-defaults
mishaschwartz Jan 23, 2024
ba2c863
Merge branch 'fix-node-details' of https://github.com/bird-house/bird…
fmigneault Jan 23, 2024
3cae728
replace missed logging call
fmigneault Jan 25, 2024
24950ba
Magpie: ensure that the `MAGPIE_ADMIN_USERNAME` variable is respected…
mishaschwartz Jan 25, 2024
adb54c7
add check_default_vars to read_basic_configs_only
fmigneault Jan 25, 2024
1e53f57
Merge branch 'fix-node-details' of https://github.com/bird-house/bird…
fmigneault Jan 25, 2024
22a161f
replace check_required_vars exit by return
fmigneault Jan 25, 2024
e17649b
add comments from PR review
fmigneault Jan 25, 2024
bcfe94c
move discover_compose_dir to resolve COMPOSE_DIR and reuse it to sour…
fmigneault Jan 26, 2024
f59a1e1
fix missing echo -> log conversions
fmigneault Jan 26, 2024
151c8a5
adjustments from PR review
fmigneault Jan 26, 2024
13392c8
move compose list resolution and 'info' mode handling before pre-dock…
fmigneault Jan 26, 2024
ccb97b5
Merge branch 'master' into fix-node-details
mishaschwartz Feb 16, 2024
193bdb1
Merge branch 'master' into fix-node-details
mishaschwartz Feb 16, 2024
85d2910
do not export __DEFAULT__ variables
fmigneault Feb 20, 2024
dbc79a3
reuse __DEFAULT__ values for env.local.example
fmigneault Feb 20, 2024
442d2f2
add COMPOSE_DIR check if provided explicitly
fmigneault Feb 20, 2024
9649cf3
revert read-configs.include.sh move + unify variables/escapes/quote-exec
fmigneault Feb 20, 2024
85a258a
fix read-configs.include.sh location in unittests
fmigneault Feb 21, 2024
ebf070f
adjust comments about __DEFAULT__ variables
fmigneault Feb 21, 2024
0dbd31d
Bump version: 2.0.6 → 2.1.0
fmigneault Feb 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,29 @@
[Unreleased](https://github.com/bird-house/birdhouse-deploy/tree/master) (latest)
------------------------------------------------------------------------------------------------------------------

[//]: # (list changes here, using '-' for each new entry, remove this when items are added)
## Changes
- Compose script utilities:
* Add `BIRDHOUSE_COLOR` option and various logging/messaging definitions in `birdhouse/scripts/logging.include.sh`.
* Replace all explicit color "logging" related `echo` in scripts by utility variables
`MSG_DEBUG`, `MSG_INFO`, `MSG_WARN` and `MSG_ERROR` as applicable per respective messages.
* Move `read-configs.include.sh` into `birdhouse/scripts` along other include scripts.
* Add `info` option (ie: `pavics-compose.sh info`) that will stop processing just before `docker-compose` call.
This can be used to run a "dry-run" of the command and validate that was is loaded is as expected, by inspecting
provided log messages.

- Defaults:
* Add multiple `SERVER_[...]` variables with defaults using previously hard coded values referring to PAVICS.
These variables use a special combination of `DELAYED_EVAL` and `OPTIONAL_VARS` definitions that can make use
of a variable formatted as `<ANY_NAME>='${__DEFAULT__<ANY_NAME>}'` that will print a warning messages indicating
that the default is employed, although *STRONGLY* recommended to be overridden. This allows a middle ground between
backward-compatible `env.local` while flagging potentially misused configurations.

## Fixes
- Canarie-API: updated references
* Use the new `SERVER_[...]` variables.
* Replace the LICENSE URL of the server node pointing
at [Ouranosinc/pavics-sdi](https://github.com/Ouranosinc/pavics-sdi) instead
of intended [bird-house/birdhouse-deploy](https://github.com/bird-house/birdhouse-deploy).

[2.0.1](https://github.com/bird-house/birdhouse-deploy/tree/2.0.1) (2023-12-11)
------------------------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,23 @@ SERVICES = {
# Do NOT modify it manually. See 'Tagging policy' in 'birdhouse/README.rst'.
'version': '2.0.1',
'releaseTime': '2023-12-11T22:30:20Z',
'institution': 'Ouranos',
'researchSubject': 'Climatology',
'institution': '${SERVER_INSTITUTION}',
'researchSubject': '${SERVER_SUBJECT}',
'supportEmail': '${SUPPORT_EMAIL}',
'category': 'Resource/Cloud Management',
'tags': ['Climatology']
'tags': [tag.strip() for tag in "${SERVER_TAGS}".split(",") if tag.strip()],
},
'stats': {
'method': '.*',
'route': '(?!)' # this will be set by CANARIE_STATS_ROUTES (see below)
},
'redirect': {
'doc': 'https://pavics-sdi.readthedocs.io/en/latest/arch/backend.html',
'releasenotes': 'https://github.com/bird-house/birdhouse-deploy/blob/master/CHANGES.md',
'support': 'https://github.com/bird-house/birdhouse-deploy/issues',
'doc': '${SERVER_DOCUMENTATION_URL}',
'releasenotes': '${SERVER_RELEASE_NOTES_URL}',
'support': '${SERVER_SUPPORT_URL}',
'source': 'https://github.com/bird-house/birdhouse-deploy',
'tryme': 'https://${PAVICS_FQDN_PUBLIC}',
'licence': 'https://pavics-sdi.readthedocs.io/en/latest/license.html',
'licence': '${SERVER_LICENSE_URL}',
'provenance': 'https://pavics-sdi.readthedocs.io/en/latest/provenance/index.html'
},
'monitoring': {} # filled in after processing everything, see end of script
Expand Down
6 changes: 5 additions & 1 deletion birdhouse/components/geoserver/pre-docker-compose-up
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ THIS_FILE="`realpath "$0"`"
THIS_DIR="`dirname "$THIS_FILE"`"
COMPOSE_DIR="$THIS_DIR/../.."

if [ -f "${COMPOSE_DIR}/scripts/logging.include.sh" ]; then
. "${COMPOSE_DIR}/scripts/logging.include.sh"
fmigneault marked this conversation as resolved.
Show resolved Hide resolved
fmigneault marked this conversation as resolved.
Show resolved Hide resolved
fi

if [ ! -f "${GEOSERVER_DATA_DIR}/global.xml" ]; then
echo "fix GeoServer data dir permission on first run only, when data dir do not exist yet."
echo "${MSG_INFO}fix GeoServer data dir permission on first run only, when data dir do not exist yet."
FIRST_RUN_ONLY=1 "$COMPOSE_DIR"/deployment/fix-geoserver-data-dir-perm
fi
43 changes: 40 additions & 3 deletions birdhouse/default.env
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,54 @@ export DELAYED_EVAL="
PAVICS_FQDN_PUBLIC
DATA_PERSIST_SHARED_ROOT
WPS_OUTPUTS_DIR
SERVER_NAME
SERVER_DESCRIPTION
SERVER_INSTITUTION
SERVER_SUBJECT
SERVER_TAGS
SERVER_DOCUMENTATION_URL
SERVER_RELEASE_NOTES_URL
SERVER_SUPPORT_URL
SERVER_LICENSE_URL
"


export SERVER_NAME=PAVICS
export SERVER_DESCRIPTION="
# Server Identification Details
# Following definitions should definitenly be updated.
# Previous defaults are defined for backward-compatibility.
# If not overridden explicitly by their non '__' prefixed variant,
# a WARN message will be displayed by pavics-compose.
export __DEFAULT__SERVER_NAME=PAVICS
fmigneault marked this conversation as resolved.
Show resolved Hide resolved
export __DEFAULT__SERVER_DESCRIPTION="
The PAVICS (Power Analytics for Visualization of Climate Science) platform is a collection of
climate analysis services served through Open Geospatial Consortium (OGC) protocols.
These services include data access, processing and visualization. Both data and algorithms
can be accessed either programmatically, through OGC-compliant clients such as QGIS or ArcGIS,
or a custom web interface.
"
export __DEFAULT__SERVER_INSTITUTION=Ouranos
export __DEFAULT__SERVER_SUBJECT=Climatology
# below can be a CSV list of tags
export __DEFAULT__SERVER_TAGS=Climatology
export __DEFAULT__SERVER_DOCUMENTATION_URL=https://pavics-sdi.readthedocs.io/en/latest/arch/backend.html
export __DEFAULT__SERVER_RELEASE_NOTES_URL=https://github.com/bird-house/birdhouse-deploy/blob/master/CHANGES.md
export __DEFAULT__SERVER_SUPPORT_URL=https://github.com/bird-house/birdhouse-deploy/issues
# NOTE:
# This value does not use the previously hard coded default.
# Previous default pointed at the wrong repository with a mismatching LICENSE file.
export __DEFAULT__SERVER_LICENSE_URL=https://github.com/bird-house/birdhouse-deploy/blob/master/LICENSE

# apply overrides or fallback above defaults with delayed evaluation
# see also: 'SUPPORT_EMAIL'
# This parameter is relevant to server details, but uses the old name for backward compatibility.
export SERVER_NAME='${__DEFAULT__SERVER_NAME}'
export SERVER_DESCRIPTION='${__DEFAULT__SERVER_DESCRIPTION}'
export SERVER_INSTITUTION='${__DEFAULT__SERVER_INSTITUTION}'
export SERVER_SUBJECT='${__DEFAULT__SERVER_SUBJECT}'
export SERVER_TAGS='${__DEFAULT__SERVER_TAGS}'
export SERVER_DOCUMENTATION_URL='${__DEFAULT__SERVER_DOCUMENTATION_URL}'
export SERVER_RELEASE_NOTES_URL='${__DEFAULT__SERVER_RELEASE_NOTES_URL}'
export SERVER_SUPPORT_URL='${__DEFAULT__SERVER_SUPPORT_URL}'
export SERVER_LICENSE_URL='${__DEFAULT__SERVER_LICENSE_URL}'

export DEFAULT_CONF_DIRS='
./components/proxy
Expand Down
4 changes: 2 additions & 2 deletions birdhouse/deployment/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ cd $COMPOSE_DIR
START_TIME="`date -Isecond`"
echo "deploy START_TIME=$START_TIME"

. "$COMPOSE_DIR/read-configs.include.sh"
. "${COMPOSE_DIR}/scripts/read-configs.include.sh"

# Read AUTODEPLOY_EXTRA_REPOS
read_basic_configs_only
Expand Down Expand Up @@ -171,7 +171,7 @@ done
cd $COMPOSE_DIR

# reload again after git pull because this file could be changed by the pull
. "$COMPOSE_DIR/read-configs.include.sh"
. "${COMPOSE_DIR}/scripts/read-configs.include.sh"

# reload again after default.env since env.local can override default.env
# (ex: JUPYTERHUB_USER_DATA_DIR)
Expand Down
2 changes: 1 addition & 1 deletion birdhouse/deployment/fix-geoserver-data-dir-perm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ THIS_DIR="`dirname "$THIS_FILE"`"
# Go to repo root.
cd $THIS_DIR/../..

. birdhouse/read-configs.include.sh
. birdhouse/scripts/read-configs.include.sh

# Get BASH_IMAGE
# Get GEOSERVER_DATA_DIR
Expand Down
2 changes: 1 addition & 1 deletion birdhouse/deployment/fix-write-perm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ THIS_DIR="`dirname "$THIS_FILE"`"
# Go to repo root.
cd $THIS_DIR/../..

. birdhouse/read-configs.include.sh
. birdhouse/scripts/read-configs.include.sh

# Get GEOSERVER_DATA_DIR, JUPYTERHUB_USER_DATA_DIR, MAGPIE_PERSIST_DIR
read_configs
Expand Down
2 changes: 1 addition & 1 deletion birdhouse/deployment/install-deploy-notebook
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if [ ! -e "$REPO_ROOT/birdhouse/deployment/trigger-deploy-notebook" ]; then
exit 2
fi

. "$REPO_ROOT/birdhouse/read-configs.include.sh"
. "$REPO_ROOT/birdhouse/scripts/read-configs.include.sh"

# Get JUPYTERHUB_USER_DATA_DIR
read_configs
Expand Down
4 changes: 2 additions & 2 deletions birdhouse/deployment/trigger-deploy-notebook
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ if [ -z "$COMPOSE_DIR" ]; then
COMPOSE_DIR="$(dirname -- "$(dirname -- "$(realpath "$0")")")"
fi

if [ -f "$COMPOSE_DIR/read-configs.include.sh" ]; then
. "$COMPOSE_DIR/read-configs.include.sh"
if [ -f "${COMPOSE_DIR}/scripts/read-configs.include.sh" ]; then
. "${COMPOSE_DIR}/scripts/read-configs.include.sh"

# Get JUPYTERHUB_USER_DATA_DIR
read_configs
Expand Down
2 changes: 1 addition & 1 deletion birdhouse/deployment/triggerdeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ START_TIME="`date -Isecond`"
echo "==========
triggerdeploy START_TIME=$START_TIME"

. "$COMPOSE_DIR/read-configs.include.sh"
. "${COMPOSE_DIR}/scripts/read-configs.include.sh"

# Read AUTODEPLOY_EXTRA_REPOS
read_basic_configs_only
Expand Down
44 changes: 26 additions & 18 deletions birdhouse/pavics-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
# * Try to keep the same behavior/code, inside and outside of the
# autodeploy container to catch error early with the autodeploy.

YELLOW=$(tput setaf 3)
RED=$(tput setaf 1)
NORMAL=$(tput sgr0)

# list of all variables to be substituted in templates
# some of these variables *could* employ provided values in 'default.env',
# but they must ultimately be defined one way or another for the server to work
Expand All @@ -34,31 +30,38 @@ OPTIONAL_VARS='
$EXTRA_PYWPS_CONFIG
$SERVER_NAME
$SERVER_DESCRIPTION
$SERVER_INSTITUTION
$SERVER_SUBJECT
$SERVER_TAGS
$SERVER_DOCUMENTATION_URL
$SERVER_RELEASE_NOTES_URL
$SERVER_SUPPORT_URL
$SERVER_LICENSE_URL
'

# we switch to the real directory of the script, so it still works when used from $PATH
# tip: ln -s /path/to/pavics-compose.sh ~/bin/
# Setup PWD for sourcing env.local.
cd $(dirname $(readlink -f $0 || realpath $0))
cd "$(dirname "$(readlink -f "$0" || realpath "$0")")" || (echo "Unresolved path [$0]" && exit 1)
fmigneault marked this conversation as resolved.
Show resolved Hide resolved

# Setup COMPOSE_DIR for sourcing env.local.
# Prevent un-expected difference when this script is run inside autodeploy
# container and manually from the host.
COMPOSE_DIR="`pwd`"

. "$COMPOSE_DIR/read-configs.include.sh"
. "${COMPOSE_DIR}/scripts/read-configs.include.sh"
read_configs # this sets ALL_CONF_DIRS

. ./scripts/get-components-json.include.sh
. ./scripts/get-services-json.include.sh
. ./scripts/get-version-json.include.sh
. "${COMPOSE_DIR}/scripts/get-components-json.include.sh"
. "${COMPOSE_DIR}/scripts/get-services-json.include.sh"
. "${COMPOSE_DIR}/scripts/get-version-json.include.sh"

for i in ${VARS}
do
v="${i}"
if [ -z "`eval "echo ${v}"`" ]
then
echo "${RED}Error${NORMAL}: Required variable $v is not set. Check env.local file."
echo "${MSG_ERROR}Required variable $v is not set. Check env.local file."
mishaschwartz marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi
done
Expand All @@ -67,15 +70,15 @@ done
# will add delay
# if [ ! -f $SSL_CERTIFICATE ]
# then
# echo "Error, SSL certificate file $SSL_CERTIFICATE is missing"
# echo "${MSG_ERROR}SSL certificate file $SSL_CERTIFICATE is missing"
# exit 1
# fi

TIMEWAIT_REUSE=$(/sbin/sysctl -n net.ipv4.tcp_tw_reuse)
if [ ${TIMEWAIT_REUSE} -eq 0 ]
if [ "${TIMEWAIT_REUSE}" -eq 0 ]
then
echo "${YELLOW}Warning:${NORMAL} the sysctl net.ipv4.tcp_tw_reuse is not enabled"
echo " It it suggested to set it to 1, otherwise the pavicscrawler may fail"
echo "${MSG_WARN}the sysctl net.ipv4.tcp_tw_reuse is not enabled. " \
"It it suggested to set it to 1, otherwise the pavicscrawler may fail."
fi

export AUTODEPLOY_EXTRA_REPOS_AS_DOCKER_VOLUMES=""
Expand All @@ -91,14 +94,14 @@ find $ALL_CONF_DIRS -name '*.template' |
while read FILE
do
DEST=${FILE%.template}
cat ${FILE} | envsubst "$VARS" | envsubst "$OPTIONAL_VARS" > ${DEST}
cat "${FILE}" | envsubst "$VARS" | envsubst "$OPTIONAL_VARS" > "${DEST}"
done

if [ x"$1" = x"up" ]; then
for adir in $ALL_CONF_DIRS; do
COMPONENT_PRE_COMPOSE_UP="$adir/pre-docker-compose-up"
if [ -x "$COMPONENT_PRE_COMPOSE_UP" ]; then
echo "executing '$COMPONENT_PRE_COMPOSE_UP'"
echo "${MSG_INFO}executing '$COMPONENT_PRE_COMPOSE_UP'"
sh -x "$COMPONENT_PRE_COMPOSE_UP"
fmigneault marked this conversation as resolved.
Show resolved Hide resolved
fi
done
Expand All @@ -108,6 +111,11 @@ create_compose_conf_list # this sets COMPOSE_CONF_LIST
echo "COMPOSE_CONF_LIST="
echo ${COMPOSE_CONF_LIST} | tr ' ' '\n' | grep -v '^-f'

if [ x"$1" = x"info" ]; then
echo "${MSG_INFO}Stopping before execution of docker-compose command."
exit 0
fmigneault marked this conversation as resolved.
Show resolved Hide resolved
fi

# the PROXY_SECURE_PORT is a little trick to make the compose file invalid without the usage of this wrapper script
PROXY_SECURE_PORT=443 HOSTNAME=${PAVICS_FQDN} docker-compose ${COMPOSE_CONF_LIST} $*
ERR=$?
Expand All @@ -116,7 +124,7 @@ ERR=$?
type post-compose 2>&1 | grep 'post-compose is a function' > /dev/null
if [ $? -eq 0 ]
then
[ ${ERR} -gt 0 ] && { echo "Error occurred with docker-compose, not running post-compose"; exit $?; }
[ ${ERR} -gt 0 ] && { echo "${MSG_ERROR}Error occurred with docker-compose, not running post-compose"; exit $?; }
post-compose $*
fi

Expand All @@ -137,7 +145,7 @@ do
for adir in $ALL_CONF_DIRS; do
COMPONENT_POST_COMPOSE_UP="$adir/post-docker-compose-up"
if [ -x "$COMPONENT_POST_COMPOSE_UP" ]; then
echo "executing '$COMPONENT_POST_COMPOSE_UP'"
echo "${MSG_INFO}executing '$COMPONENT_POST_COMPOSE_UP'"
sh -x "$COMPONENT_POST_COMPOSE_UP"
fi
done
Expand Down
4 changes: 2 additions & 2 deletions birdhouse/scripts/check-autodeploy-repos
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ THIS_FILE="`realpath "$0"`"
THIS_DIR="`dirname "$THIS_FILE"`"
COMPOSE_DIR="`dirname "$THIS_DIR"`"

if [ -f "$COMPOSE_DIR/read-configs.include.sh" ]; then
. "$COMPOSE_DIR/read-configs.include.sh"
if [ -f "${COMPOSE_DIR}/scripts/read-configs.include.sh" ]; then
. "${COMPOSE_DIR}/scripts/read-configs.include.sh"

# Get AUTODEPLOY_EXTRA_REPOS
read_configs
Expand Down
4 changes: 2 additions & 2 deletions birdhouse/scripts/check-instance-ready
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ THIS_FILE="`realpath "$0"`"
THIS_DIR="`dirname "$THIS_FILE"`"
COMPOSE_DIR="`dirname "$THIS_DIR"`"

if [ -f "$COMPOSE_DIR/read-configs.include.sh" ]; then
. "$COMPOSE_DIR/read-configs.include.sh"
if [ -f "${COMPOSE_DIR}/scripts/read-configs.include.sh" ]; then
. "${COMPOSE_DIR}/scripts/read-configs.include.sh"

# Get PAVICS_FQDN
read_configs
Expand Down
8 changes: 7 additions & 1 deletion birdhouse/scripts/check-wps-database.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash

THIS_FILE="`realpath "$0"`"
fmigneault marked this conversation as resolved.
Show resolved Hide resolved
fmigneault marked this conversation as resolved.
Show resolved Hide resolved
THIS_DIR="`dirname "$THIS_FILE"`"

if [ -f "${THIS_DIR}/logging.include.sh" ]; then
. "${THIS_DIR}/logging.include.sh"
fmigneault marked this conversation as resolved.
Show resolved Hide resolved
fi

function usage(){
cat <<EOF
Expand Down Expand Up @@ -60,7 +66,7 @@ case $2 in
docker run -ti --rm -v birdhouse_data:/data birdhouse/bird-base sqlite3 $DB
;;
*)
echo "Error, unknown operation: $2"
echo "${MSG_ERROR}unknown operation: $2"
usage
;;
esac
Expand Down
12 changes: 10 additions & 2 deletions birdhouse/scripts/clear-running-wps-jobs-in-db.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
#!/bin/sh

THIS_FILE="`realpath "$0"`"
THIS_DIR="`dirname "$THIS_FILE"`"
COMPOSE_DIR="`dirname "$THIS_DIR"`"

if [ -f "${COMPOSE_DIR}/scripts/logging.include.sh" ]; then
. "${COMPOSE_DIR}/scripts/logging.include.sh"
fmigneault marked this conversation as resolved.
Show resolved Hide resolved
fi

# eg: DB_NAME=finch
DB_NAME="$1"
if [ -z "$DB_NAME" ]; then
echo "ERROR: please provide a database name, ex: finch" 1>&2
echo "${MSG_ERROR}please provide a database name, ex: finch" 1>&2
exit 2
fi
shift
Expand All @@ -24,7 +32,7 @@ docker exec $POSTGRES_CONTAINER_NAME psql -U $POSTGRES_USER $DB_NAME -c "select

set +x
echo "
WARNING: this will crash all the above requests if currently still processing
${MSG_WARN}This will crash all the above requests if currently still processing
fmigneault marked this conversation as resolved.
Show resolved Hide resolved

Clear those jobs? (Ctrl-C to cancel, any keys to continue)"

Expand Down
Loading
Loading