parent
0790da4e32
commit
78cc1b95bb
3 changed files with 49 additions and 2 deletions
28
scripts/deploy-app.sh
Normal file
28
scripts/deploy-app.sh
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
target_host="${1:-root@sortug.com}"
|
||||
service_name="${SERVICE_NAME:-kotsukotsu}"
|
||||
current_path="${CURRENT_PATH:-/var/lib/kotsukotsu/current}"
|
||||
health_url="${HEALTH_URL:-http://127.0.0.1:5174/healthz}"
|
||||
|
||||
store_path="$(nix build --accept-flake-config --print-out-paths .#default | tail -n 1)"
|
||||
|
||||
echo "Built ${store_path}"
|
||||
echo "Copying package to ${target_host}"
|
||||
nix copy --to "ssh://${target_host}" "${store_path}"
|
||||
|
||||
echo "Activating release on ${target_host}"
|
||||
ssh "${target_host}" "
|
||||
set -euo pipefail
|
||||
ln -sfn '${store_path}' '${current_path}'
|
||||
systemctl restart '${service_name}'
|
||||
for _ in 1 2 3 4 5 6 7 8 9 10; do
|
||||
if curl -fsS '${health_url}' >/dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo 'health check failed for ${service_name}' >&2
|
||||
exit 1
|
||||
"
|
||||
Loading…
Add table
Add a link
Reference in a new issue