Files
SkyArtShop/docs/SERVER_MANAGEMENT.md
Local Server e4b3de4a46 Updatweb
2025-12-19 20:44:46 -06:00

3.6 KiB

SkyArtShop Server Management

Your SkyArtShop server is now configured to run persistently on localhost:5000 using PM2 process manager.

What's Been Set Up

  1. PM2 Process Manager - Manages your Node.js server
  2. Auto-Restart - Server automatically restarts if it crashes
  3. Boot Startup - Server starts automatically when system boots
  4. Zero restarts - Currently running with 0 crashes (stable!)

🚀 Server Status

Your server is currently ONLINE and running at:

📝 Quick Commands

Check Server Status

cd /media/pts/Website/SkyArtShop
./manage-server.sh status

View Live Logs

./manage-server.sh logs

(Press Ctrl+C to exit)

Restart Server

./manage-server.sh restart

Stop Server

./manage-server.sh stop

Start Server

./manage-server.sh start

🔍 Advanced PM2 Commands

# Detailed status
pm2 show skyartshop

# Monitor CPU/Memory in real-time
pm2 monit

# View logs (last 100 lines)
pm2 logs skyartshop --lines 100

# Clear logs
pm2 flush

# List all PM2 processes
pm2 list

🌐 Accessing Your Website

🔄 Auto-Restart Features

Your server will automatically:

  • Restart if it crashes
  • Start when you boot your computer
  • Stay running even when VS Code is closed
  • Recover from unexpected errors

📊 Log Files

Logs are stored in two locations:

PM2 Logs:

  • Output: /var/log/skyartshop/pm2-output.log
  • Errors: /var/log/skyartshop/pm2-error.log

View logs:

tail -f /var/log/skyartshop/pm2-output.log
tail -f /var/log/skyartshop/pm2-error.log

⚙️ Configuration Files

  • PM2 Config: ecosystem.config.js
  • Environment: backend/.env
  • Server Script: backend/server.js

🛑 Stopping Auto-Start

If you want to disable auto-start on boot:

pm2 unstartup systemd

To re-enable:

sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u pts --hp /home/pts
pm2 save

🔧 Troubleshooting

Server not responding?

./manage-server.sh status
# Check if status shows "online"

Check for errors in logs

./manage-server.sh logs
# or
pm2 logs skyartshop --err

Force restart

pm2 delete skyartshop
cd /media/pts/Website/SkyArtShop
pm2 start ecosystem.config.js
pm2 save

Check what's using port 5000

sudo lsof -i :5000

📁 Project Structure

/media/pts/Website/SkyArtShop/
├── backend/
│   ├── server.js          # Main server file
│   ├── .env               # Environment variables
│   └── ...
├── website/
│   ├── public/            # Public HTML pages
│   ├── admin/             # Admin panel
│   └── assets/            # CSS, JS, images
├── ecosystem.config.js    # PM2 configuration
└── manage-server.sh       # Server management script

🎯 Key Benefits

  1. No VS Code Required - Server runs independently
  2. Automatic Recovery - Restarts on crashes
  3. Boot Persistence - Starts with your system
  4. Easy Management - Simple commands via manage-server.sh
  5. Production Ready - PM2 is industry standard for Node.js

Server Manager Script: ./manage-server.sh {start|stop|restart|status|logs}

For help: ./manage-server.sh (shows usage)