# 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: - **URL**: - **Mode**: Development - **Database**: PostgreSQL (skyartshop) - **Process Manager**: PM2 ## 📝 Quick Commands ### Check Server Status ```bash cd /media/pts/Website/SkyArtShop ./manage-server.sh status ``` ### View Live Logs ```bash ./manage-server.sh logs ``` (Press Ctrl+C to exit) ### Restart Server ```bash ./manage-server.sh restart ``` ### Stop Server ```bash ./manage-server.sh stop ``` ### Start Server ```bash ./manage-server.sh start ``` ## 🔍 Advanced PM2 Commands ```bash # 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**: - **Shop Page**: - **Admin Login**: ## 🔄 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:** ```bash 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: ```bash pm2 unstartup systemd ``` To re-enable: ```bash sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u pts --hp /home/pts pm2 save ``` ## 🔧 Troubleshooting ### Server not responding? ```bash ./manage-server.sh status # Check if status shows "online" ``` ### Check for errors in logs ```bash ./manage-server.sh logs # or pm2 logs skyartshop --err ``` ### Force restart ```bash pm2 delete skyartshop cd /media/pts/Website/SkyArtShop pm2 start ecosystem.config.js pm2 save ``` ### Check what's using port 5000 ```bash 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)