3e5ae6d5d16c0133454442b8811c9573d4c76105
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
-
Install dependencies:
pip install -r requirements.txt -
Run the server:
python app.pyThe server will run on
http://localhost:5000
Production Deployment
Using Gunicorn
pip install -r requirements.txt
gunicorn -w 4 -b 0.0.0.0:5000 app:app
Using Docker
docker build -t update-server .
docker run -p 5000:5000 update-server
Using Docker Compose
From the parent directory:
docker-compose up update-server
Production with Nginx (HTTPS)
Configure nginx as a reverse proxy to handle HTTPS on port 443:
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:
{
"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 endpointsGET /health- Health checkGET /api/versions- Get all bot versionsGET /api/version/<bot_name>- Get specific bot version
Example:
curl https://updts.slfhstd.uk/api/version/TestPostsBot
Response:
{
"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
Description
Languages
Python
97.8%
Dockerfile
2.2%