Initial LisgloSIPS V2 implementation
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
health_url="${LISGLOSIPS_HEALTH_URL:-http://127.0.0.1:3000/api/v2/health/ready}"
|
||||
services=(
|
||||
mysql
|
||||
redis-server
|
||||
nginx
|
||||
lisglosips@api
|
||||
lisglosips@cdr-worker
|
||||
lisglosips@recording-worker
|
||||
heplify-server
|
||||
lisglosips-prometheus.service
|
||||
grafana-server
|
||||
)
|
||||
|
||||
echo "== release =="
|
||||
readlink -f /opt/lisglosips/current
|
||||
test -L /opt/lisglosips/current
|
||||
test -d "$(readlink -f /opt/lisglosips/current)"
|
||||
|
||||
echo "== services =="
|
||||
for service in "${services[@]}"; do
|
||||
state="$(systemctl is-active "$service" || true)"
|
||||
printf '%s\t%s\n' "$service" "$state"
|
||||
test "$state" = active
|
||||
done
|
||||
|
||||
echo "== api =="
|
||||
curl --max-time 5 --fail --silent "$health_url"
|
||||
echo
|
||||
|
||||
echo "== nginx =="
|
||||
nginx -t
|
||||
|
||||
echo "== backups =="
|
||||
find /data/backups/mysql -mindepth 1 -maxdepth 1 -type d | sort | tail -1
|
||||
find /data/backups/redis -mindepth 1 -maxdepth 1 -type d | sort | tail -1
|
||||
|
||||
echo "preflight ok"
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "usage: $0 /opt/lisglosips/releases/<release-id>" >&2
|
||||
exit 64
|
||||
fi
|
||||
|
||||
target="$1"
|
||||
case "$target" in
|
||||
/opt/lisglosips/releases/*) ;;
|
||||
*)
|
||||
echo "target must be under /opt/lisglosips/releases" >&2
|
||||
exit 64
|
||||
;;
|
||||
esac
|
||||
|
||||
target="$(readlink -f "$target")"
|
||||
test -d "$target"
|
||||
test -f "$target/package.json"
|
||||
|
||||
previous="$(readlink -f /opt/lisglosips/current)"
|
||||
echo "previous=$previous"
|
||||
echo "target=$target"
|
||||
|
||||
ln -sfn "$target" /opt/lisglosips/current
|
||||
systemctl restart lisglosips@api lisglosips@cdr-worker lisglosips@recording-worker
|
||||
nginx -t
|
||||
systemctl reload nginx
|
||||
curl --max-time 10 --fail --silent http://127.0.0.1:3000/api/v2/health/ready
|
||||
echo
|
||||
echo "rollback ok"
|
||||
Reference in New Issue
Block a user