3.6 KiB
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
- PM2 Process Manager - Manages your Node.js server
- Auto-Restart - Server automatically restarts if it crashes
- Boot Startup - Server starts automatically when system boots
- Zero restarts - Currently running with 0 crashes (stable!)
🚀 Server Status
Your server is currently ONLINE and running at:
- URL: http://localhost:5000
- Mode: Development
- Database: PostgreSQL (skyartshop)
- Process Manager: PM2
📝 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
- Homepage: http://localhost:5000
- Shop Page: http://localhost:5000/shop.html
- Admin Login: http://localhost:5000/admin/login.html
🔄 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
- No VS Code Required - Server runs independently
- Automatic Recovery - Restarts on crashes
- Boot Persistence - Starts with your system
- Easy Management - Simple commands via manage-server.sh
- 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)