Files
scaev/AUTOSTART_SETUP.md
2025-12-07 12:32:39 +01:00

121 lines
2.7 KiB
Markdown

# Auto-Start Setup Guide
The monitor doesn't run automatically yet. Choose your setup based on your server OS:
---
## Linux Server (Systemd Service) ⭐ RECOMMENDED
**Install:**
```bash
cd /home/tour/scaev
chmod +x install_service.sh
./install_service.sh
```
**The service will:**
- ✅ Start automatically on server boot
- ✅ Restart automatically if it crashes
- ✅ Log to `~/scaev/logs/monitor.log`
- ✅ Poll every 30 minutes
**Management commands:**
```bash
sudo systemctl status scaev-monitor # Check if running
sudo systemctl stop scaev-monitor # Stop
sudo systemctl start scaev-monitor # Start
sudo systemctl restart scaev-monitor # Restart
journalctl -u scaev-monitor -f # Live logs
tail -f ~/scaev/logs/monitor.log # Monitor log file
```
---
## Windows (Task Scheduler)
**Install (Run as Administrator):**
```powershell
cd C:\vibe\scaev
.\setup_windows_task.ps1
```
**The task will:**
- ✅ Start automatically on Windows boot
- ✅ Restart automatically if it crashes (up to 3 times)
- ✅ Run as SYSTEM user
- ✅ Poll every 30 minutes
**Management:**
1. Open Task Scheduler (`taskschd.msc`)
2. Find `ScaevAuctionMonitor` in Task Scheduler Library
3. Right-click to Run/Stop/Disable
**Or via PowerShell:**
```powershell
Start-ScheduledTask -TaskName "ScaevAuctionMonitor"
Stop-ScheduledTask -TaskName "ScaevAuctionMonitor"
Get-ScheduledTask -TaskName "ScaevAuctionMonitor" | Get-ScheduledTaskInfo
```
---
## Alternative: Cron Job (Linux)
**For simpler setup without systemd:**
```bash
# Edit crontab
crontab -e
# Add this line (runs on boot and restarts every hour if not running)
@reboot cd /home/tour/scaev && python3 src/monitor.py 30 >> logs/monitor.log 2>&1
0 * * * * pgrep -f "monitor.py" || (cd /home/tour/scaev && python3 src/monitor.py 30 >> logs/monitor.log 2>&1 &)
```
---
## Verify It's Working
**Check process is running:**
```bash
# Linux
ps aux | grep monitor.py
# Windows
tasklist | findstr python
```
**Check logs:**
```bash
# Linux
tail -f ~/scaev/logs/monitor.log
# Windows
# Check Task Scheduler history
```
**Check database is updating:**
```bash
# Last modified time should update every 30 minutes
ls -lh C:/mnt/okcomputer/output/cache.db
```
---
## Troubleshooting
**Service won't start:**
1. Check Python path is correct in service file
2. Check working directory exists
3. Check user permissions
4. View error logs: `journalctl -u scaev-monitor -n 50`
**Monitor stops after a while:**
- Check disk space for logs
- Check rate limiting isn't blocking requests
- Increase RestartSec in service file
**Database locked errors:**
- Ensure only one monitor instance is running
- Add timeout to SQLite connections in config