34 lines
936 B
Bash
Executable File
34 lines
936 B
Bash
Executable File
#!/bin/bash
|
|
# Server Update Script: Pull latest main, build, and restart PM2
|
|
set -e
|
|
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
echo -e "${YELLOW}Step 1: Pulling latest changes from GitHub (main)...${NC}"
|
|
cd /root/My-Weekly-ToDo-List
|
|
git checkout main
|
|
git pull origin main
|
|
|
|
echo -e "${YELLOW}Step 2: Installing dependencies...${NC}"
|
|
npm install
|
|
|
|
echo -e "${YELLOW}Step 3: Updating database schema (Safe Migrate)...${NC}"
|
|
npx prisma migrate deploy
|
|
|
|
echo -e "${YELLOW}Step 4: Regenerating Prisma client...${NC}"
|
|
npx prisma generate
|
|
|
|
echo -e "${YELLOW}Step 5: Building application...${NC}"
|
|
npm run build
|
|
|
|
echo -e "${YELLOW}Step 6: Restarting server with PM2 (Standalone Mode)...${NC}"
|
|
# Delete old process if it exists to ensure fresh config
|
|
pm2 delete my-weekly-todo || true
|
|
PORT=3002 pm2 start .next/standalone/server.js --name "my-weekly-todo"
|
|
pm2 save
|
|
|
|
echo -e "${GREEN}Update complete! App is running on LXC.${NC}"
|
|
pm2 list
|