109 lines
2.4 KiB
Markdown
109 lines
2.4 KiB
Markdown
# Update Server
|
|
|
|
Flask-based update server that bots query to check for new versions and send modmail notifications when updates are available.
|
|
|
|
## Setup
|
|
|
|
### Local Development
|
|
1. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
2. Run the server:
|
|
```bash
|
|
python app.py
|
|
```
|
|
The server will run on `http://localhost:5000`
|
|
|
|
### Production Deployment
|
|
|
|
#### Using Gunicorn
|
|
```bash
|
|
pip install -r requirements.txt
|
|
gunicorn -w 4 -b 0.0.0.0:5000 app:app
|
|
```
|
|
|
|
#### Using Docker
|
|
```bash
|
|
docker build -t update-server .
|
|
docker run -p 5000:5000 update-server
|
|
```
|
|
|
|
#### Using Docker Compose
|
|
From the parent directory:
|
|
```bash
|
|
docker-compose up update-server
|
|
```
|
|
|
|
### Production with Nginx (HTTPS)
|
|
Configure nginx as a reverse proxy to handle HTTPS on port 443:
|
|
|
|
```nginx
|
|
server {
|
|
listen 443 ssl http2;
|
|
server_name updts.slfhstd.uk;
|
|
|
|
ssl_certificate /path/to/cert.pem;
|
|
ssl_certificate_key /path/to/key.pem;
|
|
|
|
location / {
|
|
proxy_pass http://localhost:5000;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
}
|
|
```
|
|
|
|
## Managing Versions
|
|
|
|
Edit `versions.json` to add, update, or remove bots:
|
|
|
|
```json
|
|
{
|
|
"TestPostsBot": {
|
|
"version": "0.2",
|
|
"changelog_url": "https://github.com/yourrepo/releases/tag/v0.2"
|
|
},
|
|
"AnotherBot": {
|
|
"version": "1.0",
|
|
"changelog_url": "https://github.com/yourrepo/AnotherBot/releases"
|
|
}
|
|
}
|
|
```
|
|
|
|
When you update the version here, all connected bots will detect the change and send modmail to their respective subreddits automatically.
|
|
|
|
## API Endpoints
|
|
|
|
- `GET /` - Server info and available endpoints
|
|
- `GET /health` - Health check
|
|
- `GET /api/versions` - Get all bot versions
|
|
- `GET /api/version/<bot_name>` - Get specific bot version
|
|
|
|
Example:
|
|
```bash
|
|
curl https://updts.slfhstd.uk/api/version/TestPostsBot
|
|
```
|
|
|
|
Response:
|
|
```json
|
|
{
|
|
"version": "0.2",
|
|
"changelog_url": "https://github.com/yourrepo/releases/tag/v0.2"
|
|
}
|
|
```
|
|
|
|
## Logs
|
|
|
|
Update check requests are logged to `update_checks.log` with timestamps and bot names.
|
|
|
|
## Hosting Options
|
|
|
|
- **Heroku** - Easy deployment with free tier
|
|
- **Railway.app** - Simple alternative to Heroku
|
|
- **DigitalOcean/AWS/GCP** - Full control, more expensive
|
|
- **VPS with Nginx** - Most control, requires setup
|