-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh.example
More file actions
62 lines (52 loc) · 1.55 KB
/
deploy.sh.example
File metadata and controls
62 lines (52 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Vel Deploy Script — Example
#
# The production deploy script is at sdk/vel/deploy.sh and auto-detects
# your install directory, Go path, and systemd service name.
#
# To use it:
# cp sdk/vel/deploy.sh deploy.sh
# chmod +x deploy.sh
# ./deploy.sh
#
# Or run it directly:
# bash sdk/vel/deploy.sh
#
# If you need a customized deploy script, copy this file to deploy.sh
# and edit the variables below.
set -e
# --- Customize these if needed ---
# PROD_DIR defaults to the directory containing this script
PROD_DIR="$(cd "$(dirname "$0")" && pwd)"
# Auto-detect Go
GO="$(which go 2>/dev/null || echo /usr/local/go/bin/go)"
# Auto-detect systemd service name
SERVICE_NAME=""
for svc in vel vel-staging; do
unit_path=$(systemctl show "$svc" -p FragmentPath --value 2>/dev/null || true)
if [ -n "$unit_path" ] && grep -q "$PROD_DIR" "$unit_path" 2>/dev/null; then
SERVICE_NAME="$svc"
break
fi
done
if [ -z "$SERVICE_NAME" ]; then
echo "❌ Could not auto-detect systemd service for $PROD_DIR"
echo " Set SERVICE_NAME manually in this script."
exit 1
fi
echo "⚡ Vel Deploy → $SERVICE_NAME"
echo ""
cd "$PROD_DIR/vel"
git pull --ff-only 2>/dev/null || echo " (pull failed — skipping)"
echo "🔨 Building..."
$GO run . build
echo "🔄 Restarting $SERVICE_NAME..."
sudo systemctl restart "$SERVICE_NAME"
sleep 2
if sudo systemctl is-active --quiet "$SERVICE_NAME"; then
echo "✅ Deploy complete!"
else
echo "❌ Service failed to start!"
sudo journalctl -u "$SERVICE_NAME" --no-pager -n 20
exit 1
fi