adding backup and data perstance accross devices
This commit is contained in:
+14
-14
@@ -2,24 +2,24 @@
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PID_FILE="$ROOT_DIR/.vite.pid"
|
||||
|
||||
stop_server() {
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
OLD_PID=$(cat "$PID_FILE")
|
||||
if kill -0 "$OLD_PID" 2>/dev/null; then
|
||||
echo "Stopping existing Vite server (PID $OLD_PID)..."
|
||||
kill "$OLD_PID"
|
||||
stop_pid_file() {
|
||||
local pid_file="$1"
|
||||
local label="$2"
|
||||
if [ -f "$pid_file" ]; then
|
||||
local old_pid
|
||||
old_pid=$(cat "$pid_file")
|
||||
if kill -0 "$old_pid" 2>/dev/null; then
|
||||
echo "Stopping $label (PID $old_pid)..."
|
||||
kill "$old_pid"
|
||||
sleep 1
|
||||
fi
|
||||
rm -f "$PID_FILE"
|
||||
rm -f "$pid_file"
|
||||
fi
|
||||
}
|
||||
|
||||
start_server() {
|
||||
echo "Restarting Vite server using setup.sh..."
|
||||
exec "$ROOT_DIR/setup.sh"
|
||||
}
|
||||
stop_pid_file "$ROOT_DIR/.api.pid" "API server"
|
||||
stop_pid_file "$ROOT_DIR/.vite.pid" "Vite server"
|
||||
|
||||
stop_server
|
||||
start_server
|
||||
echo "Restarting via setup.sh..."
|
||||
exec "$ROOT_DIR/setup.sh"
|
||||
Reference in New Issue
Block a user