Simplify logic for stopping the server in configure-tde-server.sh

I run multiple instances of PostgreSQL on my machine so I would rather
not have it rely on using pgrep to detect if the server is running.

To make this new code more reliable we add set -e so the script aborts
directly e.g. if the port is already in use.
pull/209/head
Andreas Karlsson 7 months ago committed by Andreas Karlsson
parent c35778b45b
commit 4e848ea9f4
  1. 15
      ci_scripts/configure-tde-server.sh

@ -1,4 +1,6 @@
#!/bin/bash
set -e
# This script is used to configure a TDE server for testing purposes.
export TDE_MODE=1
@ -10,16 +12,11 @@ cd "$SCRIPT_DIR/.."
export PATH=$INSTALL_DIR/bin:$PATH
export PGDATA=$INSTALL_DIR/data
if pgrep -x "postgres" > /dev/null; then
pg_ctl -D "$PGDATA" stop
fi
if pgrep -x "postgres" > /dev/null; then
echo "Error: a postgres process is already running"
exit 1
fi
if [ -d "$PGDATA" ]; then
if pg_ctl -D "$PGDATA" status >/dev/null; then
pg_ctl -D "$PGDATA" stop
fi
rm -rf "$PGDATA"
fi

Loading…
Cancel
Save