fix: deploy waits for port 1999 to be free before starting service

This commit is contained in:
juanatsap
2026-04-09 23:10:47 +01:00
parent 9018edd21a
commit 837e6fac9d
+21 -3
View File
@@ -75,10 +75,28 @@ jobs:
sudo cp config/systemd/cv.service /etc/systemd/system/$SERVICE_NAME.service
sudo systemctl daemon-reload
echo "🔄 Restarting service..."
sudo systemctl restart $SERVICE_NAME
echo "🔄 Stopping service..."
sudo systemctl stop $SERVICE_NAME || true
echo "⏳ Waiting for service to start..."
# Wait for port to be released (max 15s)
echo "⏳ Waiting for port 1999 to be free..."
for i in $(seq 1 15); do
if ! sudo fuser 1999/tcp >/dev/null 2>&1; then
echo "✅ Port 1999 free after ${i}s"
break
fi
if [ $i -eq 15 ]; then
echo "⚠️ Force-killing port 1999..."
sudo fuser -k 1999/tcp 2>/dev/null || true
sleep 1
fi
sleep 1
done
echo "🔄 Starting service..."
sudo systemctl start $SERVICE_NAME
echo "⏳ Waiting for health check..."
sleep 3
# Check service status