ops: add native systemd user deployment
This commit is contained in:
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root="/home/zheromiku/dobotai-platform"
|
||||
go_bin="${GO_BIN:-/home/zheromiku/.local/share/go1.26.5/bin/go}"
|
||||
bin_dir="$root/bin"
|
||||
current="$bin_dir/dobotai"
|
||||
next="$bin_dir/dobotai.new"
|
||||
previous="$bin_dir/dobotai.prev"
|
||||
service="dobotai.service"
|
||||
|
||||
mkdir -p "$bin_dir"
|
||||
cd "$root"
|
||||
|
||||
"$go_bin" build -trimpath -o "$next" ./cmd/dobotai
|
||||
chmod 0755 "$next"
|
||||
|
||||
if [[ -f "$current" ]]; then
|
||||
cp -p "$current" "$previous"
|
||||
fi
|
||||
mv -f "$next" "$current"
|
||||
|
||||
systemctl --user restart "$service"
|
||||
|
||||
for _ in $(seq 1 30); do
|
||||
if curl --noproxy '*' --fail --silent --max-time 2 http://127.0.0.1:8090/healthz >/dev/null; then
|
||||
echo "DOBOTAI_DEPLOY_OK"
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "DobotAI health check failed; attempting binary rollback" >&2
|
||||
if [[ -f "$previous" ]]; then
|
||||
cp -p "$previous" "$current"
|
||||
systemctl --user restart "$service"
|
||||
fi
|
||||
systemctl --user status "$service" --no-pager >&2 || true
|
||||
exit 1
|
||||
Reference in New Issue
Block a user