Skip to content

Commit c6c1b7d

Browse files
committed
feat(service): add sync-restart convenience command
Add make sync-restart for easy updates: - Auto-detects systemd service vs tmux-based installation - Pulls latest code via make sync - Restarts services appropriately - Works for both native and ARK-OS installations Usage: make sync-restart bash scripts/service/sync_and_restart.sh
1 parent 57eb5fa commit c6c1b7d

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ sync:
161161

162162
update: sync
163163

164+
sync-restart:
165+
@bash scripts/service/sync_and_restart.sh
166+
164167
# ============================================================================
165168
# Maintenance
166169
# ============================================================================
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
# ============================================================================
3+
# PixEagle Sync & Restart - Works for both Native and ARK-OS installations
4+
# ============================================================================
5+
# Pulls latest code from GitHub and restarts services appropriately.
6+
#
7+
# Usage:
8+
# bash scripts/service/sync_and_restart.sh
9+
# make sync-restart (if added to Makefile)
10+
# ============================================================================
11+
12+
set -e
13+
14+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
16+
17+
cd "$PROJECT_ROOT"
18+
19+
echo ""
20+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
21+
echo " PixEagle Sync & Restart"
22+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
23+
echo ""
24+
25+
# Step 1: Sync code
26+
echo "→ Pulling latest code from GitHub..."
27+
make sync || { echo "ERROR: Sync failed"; exit 1; }
28+
29+
# Step 2: Detect installation type and restart
30+
if systemctl --user is-active pixeagle.service >/dev/null 2>&1; then
31+
# ARK-OS managed service (or native systemd service)
32+
echo ""
33+
echo "→ Detected systemd service - restarting..."
34+
systemctl --user restart pixeagle
35+
sleep 2
36+
37+
if systemctl --user is-active pixeagle.service >/dev/null 2>&1; then
38+
echo "✓ Service restarted successfully"
39+
echo ""
40+
echo " Status: systemctl --user status pixeagle"
41+
echo " Logs: journalctl --user -u pixeagle -f"
42+
else
43+
echo "✗ Service failed to start - check logs:"
44+
echo " journalctl --user -u pixeagle -n 50"
45+
exit 1
46+
fi
47+
48+
elif tmux has-session -t pixeagle 2>/dev/null; then
49+
# Native tmux-based installation
50+
echo ""
51+
echo "→ Detected tmux session - restarting..."
52+
make stop
53+
sleep 1
54+
make run
55+
56+
if tmux has-session -t pixeagle 2>/dev/null; then
57+
echo "✓ Services restarted successfully"
58+
echo ""
59+
echo " Attach: make attach"
60+
echo " Logs: make logs"
61+
else
62+
echo "✗ Services failed to start"
63+
exit 1
64+
fi
65+
66+
else
67+
# Not currently running
68+
echo ""
69+
echo "⚠ PixEagle is not currently running"
70+
echo ""
71+
echo "To start:"
72+
echo " Native: make run"
73+
echo " Service: systemctl --user start pixeagle"
74+
echo ""
75+
fi
76+
77+
echo ""
78+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
79+
echo ""

0 commit comments

Comments
 (0)