This commit is contained in:
2026-03-13 13:22:46 +00:00
parent cf7b70b21e
commit 97a9f3fd9a
7 changed files with 571 additions and 35 deletions
+81 -15
View File
@@ -2,6 +2,13 @@
Flask-based update server that bots query to check for new versions and send modmail notifications when updates are available.
## Features
- **API Server** (Port 5555) - Bots query this for version information
- **Admin GUI** (Port 5566) - Web interface to easily manage bot versions
- Simple JSON-based version storage
- Health check endpoint
## Setup
### Local Development
@@ -14,32 +21,32 @@ Flask-based update server that bots query to check for new versions and send mod
```bash
python app.py
```
The server will run on `http://localhost:5000`
- API Server: http://localhost:5555
- Admin GUI: http://localhost:5566
### 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
docker run -p 5555:5555 -p 5566:5566 update-server
```
#### Using Docker Compose
From the parent directory:
```bash
docker-compose up update-server
docker-compose up botupdateserver
```
This exposes:
- Port 5555 for API calls (public-facing)
- Port 5566 for Admin GUI (should be protected, e.g., behind Authentik)
### Production with Nginx (HTTPS)
Configure nginx as a reverse proxy to handle HTTPS on port 443:
Configure nginx as a reverse proxy:
```nginx
# Public API endpoint
server {
listen 443 ssl http2;
server_name updts.slfhstd.uk;
@@ -48,7 +55,27 @@ server {
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://localhost:5000;
proxy_pass http://localhost:5555;
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;
}
}
# Admin GUI with authentication (Authentik, etc.)
server {
listen 443 ssl http2;
server_name updts-admin.slfhstd.uk;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
# Protect with Authentik (or your auth system)
auth_request /auth;
location / {
proxy_pass http://localhost:5566;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -59,7 +86,18 @@ server {
## Managing Versions
Edit `versions.json` to add, update, or remove bots:
### Using the Admin GUI
1. Navigate to `http://localhost:5566` (or your admin domain for production)
2. Fill in the bot details:
- **Bot Name**: The name of the bot (e.g., `TestPostsBot`)
- **Version**: The current version (e.g., `0.2`)
- **Changelog URL**: (Optional) Link to the changelog
3. Click "Save Version"
4. View all current versions in the right panel
5. Edit by clicking "Edit" on any bot, or delete with "Delete"
### Manual Edit (versions.json)
If preferred, directly edit `versions.json`:
```json
{
@@ -74,10 +112,9 @@ Edit `versions.json` to add, update, or remove bots:
}
```
When you update the version here, all connected bots will detect the change and send modmail to their respective subreddits automatically.
## API Endpoints
## API Endpoints (Port 5555)
### Public API
- `GET /` - Server info and available endpoints
- `GET /health` - Health check
- `GET /api/versions` - Get all bot versions
@@ -96,10 +133,39 @@ Response:
}
```
### Admin API (Port 5566)
**Note:** These endpoints should be protected. Secure with Authentik or another authentication method.
#### Add/Update Version
```bash
curl -X POST http://localhost:5566/admin/api/add \
-H "Content-Type: application/json" \
-d '{
"bot_name": "TestPostsBot",
"version": "0.3",
"changelog_url": "https://github.com/yourrepo/releases/tag/v0.3"
}'
```
#### Delete Version
```bash
curl -X POST http://localhost:5566/admin/api/delete \
-H "Content-Type: application/json" \
-d '{"bot_name": "TestPostsBot"}'
```
## Logs
Update check requests are logged to `update_checks.log` with timestamps and bot names.
## Architecture
- **API Server (Port 5555)**: Public endpoint for bots to check versions
- **Admin GUI (Port 5566)**: Web interface for managing versions
- **Single versioning source**: Both use the same `versions.json` file
- **No authentication built-in**: Use a reverse proxy (Authentik, etc.) for security
## Hosting Options
- **Heroku** - Easy deployment with free tier