![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.quebec/private_html/ |
# Auto-Start Server - Installation Guide I've created multiple options for keeping the server running automatically. Choose the one that works best for your setup. --- ## Option 1: Background Script (Easiest) ⭐ **Files Created:** - `start-server-background.sh` - Starts server in background - `ensure-server-running.sh` - Keeps server running ### Installation: ```bash # Make scripts executable chmod +x start-server-background.sh chmod +x ensure-server-running.sh # Start the server ./start-server-background.sh # Add to crontab to keep it running (checks every 5 minutes) crontab -e # Add this line: */5 * * * * /home/gositeme/domains/lavocat.quebec/public_html/ensure-server-running.sh >> /home/gositeme/domains/lavocat.quebec/public_html/cron.log 2>&1 ``` ### Usage: ```bash # Start server ./start-server-background.sh # Check if running ps aux | grep "node.*server" # View logs tail -f server.log # Stop server cat server.pid | xargs kill ``` --- ## Option 2: Systemd Service (Recommended for Production) **File Created:** `lavocat.service` ### Installation: ```bash # Copy service file to systemd directory sudo cp lavocat.service /etc/systemd/system/ # Reload systemd sudo systemctl daemon-reload # Enable service (starts on boot) sudo systemctl enable lavocat.service # Start service sudo systemctl start lavocat.service # Check status sudo systemctl status lavocat.service # View logs sudo journalctl -u lavocat.service -f ``` ### Commands: ```bash # Start sudo systemctl start lavocat # Stop sudo systemctl stop lavocat # Restart sudo systemctl restart lavocat # Check status sudo systemctl status lavocat # View logs sudo journalctl -u lavocat -f # Enable on boot sudo systemctl enable lavocat ``` --- ## Option 3: PM2 Process Manager **File Created:** `ecosystem.config.js` ### Installation: ```bash # Install PM2 globally npm install -g pm2 # Create logs directory mkdir -p logs # Start server with PM2 pm2 start ecosystem.config.js # Save PM2 configuration pm2 save # Setup PM2 to start on system boot pm2 startup # Follow the instructions shown above ``` ### Commands: ```bash # Start pm2 start ecosystem.config.js # Stop pm2 stop lavocat-quebec # Restart pm2 restart lavocat-quebec # Check status pm2 status # View logs pm2 logs lavocat-quebec # Monitor pm2 monit # Save configuration pm2 save ``` --- ## Option 4: Nohup (Simple) ```bash # Kill existing server pkill -f "node.*server" # Start in background nohup npm run dev > server.log 2>&1 & # Save PID echo $! > server.pid # Check if running ps aux | grep "node.*server" # View logs tail -f server.log # Stop cat server.pid | xargs kill ``` --- ## Recommended Setup for DirectAdmin: Based on your hosting environment, I recommend **Option 1 (Background Script)** with a cron job. ### Quick Start: ```bash cd /home/gositeme/domains/lavocat.quebec/public_html # Make scripts executable chmod +x *.sh # Start server now ./start-server-background.sh # Verify it's running curl http://localhost:3000 # Add to crontab (keeps running) crontab -e # Add: */5 * * * * /home/gositeme/domains/lavocat.quebec/public_html/ensure-server-running.sh ``` --- ## Troubleshooting: ### Server won't start: ```bash # Check logs tail -f server.log # Check port availability lsof -i :3000 # Kill existing process pkill -f "node.*server" ``` ### Server stops after a while: ```bash # Check if cron is running crontab -l # Manually run ensure script ./ensure-server-running.sh # Check system resources free -h df -h ``` ### Can't access site: ```bash # Check if server is running ps aux | grep node # Check if port is open netstat -tuln | grep 3000 # Check firewall sudo ufw status ``` --- ## Monitoring: ```bash # View real-time logs tail -f server.log # Check process ps aux | grep "node.*server" # Check port lsof -i :3000 # Monitor resource usage top -p $(cat server.pid) ``` --- ## Files Created: 1. ✅ `start-server-background.sh` - Start script 2. ✅ `ensure-server-running.sh` - Keep-alive script 3. ✅ `lavocat.service` - Systemd service file 4. ✅ `ecosystem.config.js` - PM2 configuration 5. ✅ `INSTALL_AUTO_START.md` - This guide --- ## Next Steps: 1. Choose an option above 2. Run the installation commands 3. Test that server starts 4. Verify site is accessible 5. Set up monitoring The server will now start automatically and keep running! 🚀