fix(lxc): refactor boot and update scripts for safe migrations and standalone mode
chore(release): bump version to 1.8.6
This commit is contained in:
parent
dad44ca384
commit
f70a235c57
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "my-weekly-todo-list",
|
||||
"version": "1.8.5",
|
||||
"version": "1.8.6",
|
||||
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@ -16,35 +16,42 @@ log "=== Boot update started ==="
|
||||
|
||||
cd "$APP_DIR"
|
||||
|
||||
# Check and ensure we are on main branch
|
||||
log "Ensuring main branch..."
|
||||
git checkout main 2>&1 | tee -a "$LOG_FILE"
|
||||
|
||||
# Check if there are remote changes
|
||||
log "Fetching from origin..."
|
||||
git fetch origin main 2>&1 | tee -a "$LOG_FILE"
|
||||
|
||||
LOCAL=$(git rev-parse HEAD)
|
||||
REMOTE=$(git rev-parse origin/main)
|
||||
NEXT_DIR="$APP_DIR/.next"
|
||||
|
||||
if [ "$LOCAL" = "$REMOTE" ]; then
|
||||
log "Already up-to-date. No rebuild needed."
|
||||
if [ "$LOCAL" = "$REMOTE" ] && [ -d "$NEXT_DIR" ]; then
|
||||
log "Already up-to-date and .next directory exists. No rebuild needed."
|
||||
log "=== Boot update finished (no changes) ==="
|
||||
exit 0
|
||||
fi
|
||||
|
||||
log "Changes detected. Updating from $LOCAL to $REMOTE"
|
||||
|
||||
if [ "$LOCAL" != "$REMOTE" ]; then
|
||||
log "Changes detected. Updating from $LOCAL to "$REMOTE""
|
||||
log "Pulling latest changes..."
|
||||
git checkout main 2>&1 | tee -a "$LOG_FILE"
|
||||
git pull origin main 2>&1 | tee -a "$LOG_FILE"
|
||||
|
||||
log "Installing dependencies..."
|
||||
npm install 2>&1 | tee -a "$LOG_FILE"
|
||||
fi
|
||||
|
||||
log "Updating database schema..."
|
||||
npx prisma db push 2>&1 | tee -a "$LOG_FILE"
|
||||
if [ ! -d "$NEXT_DIR" ] || [ "$LOCAL" != "$REMOTE" ]; then
|
||||
log "Updating database schema (Safe Migrate)..."
|
||||
npx prisma migrate deploy 2>&1 | tee -a "$LOG_FILE"
|
||||
|
||||
log "Regenerating Prisma client..."
|
||||
npx prisma generate 2>&1 | tee -a "$LOG_FILE"
|
||||
|
||||
log "Building application..."
|
||||
npm run build 2>&1 | tee -a "$LOG_FILE"
|
||||
fi
|
||||
|
||||
log "=== Boot update finished (rebuilt successfully) ==="
|
||||
log "=== Boot update finished (verified/rebuilt) ==="
|
||||
|
||||
@ -14,8 +14,8 @@ git pull origin main
|
||||
echo -e "${YELLOW}Step 2: Installing dependencies...${NC}"
|
||||
npm install
|
||||
|
||||
echo -e "${YELLOW}Step 3: Updating database schema...${NC}"
|
||||
npx prisma db push
|
||||
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
|
||||
@ -23,8 +23,10 @@ npx prisma generate
|
||||
echo -e "${YELLOW}Step 5: Building application...${NC}"
|
||||
npm run build
|
||||
|
||||
echo -e "${YELLOW}Step 6: Restarting server with PM2...${NC}"
|
||||
pm2 restart my-weekly-todo || pm2 start npm --name "my-weekly-todo" -- start
|
||||
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
|
||||
pm2 start .next/standalone/server.js --name "my-weekly-todo"
|
||||
pm2 save
|
||||
|
||||
echo -e "${GREEN}Update complete! App is running on LXC.${NC}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user