Configuration¶
Configure Scrapazoid to meet your needs.
Environment Variables¶
Create a .env file in the project root:
# Flask Configuration
FLASK_ENV=development
SECRET_KEY=your-secret-key-here-change-in-production
# Database
DATABASE_URL=sqlite:///scrapazoid_dev.db
# Execution Settings
MAX_EXECUTION_TIME=300
MAX_CONCURRENT_EXECUTIONS_PER_USER=3
# Screenshot Settings
SCREENSHOT_RETENTION_DAYS=7
Configuration Options¶
MAX_EXECUTION_TIME¶
Default: 300 (5 minutes)
Maximum time in seconds a script can run before being terminated.
Warning
Setting this too high may allow scripts to consume resources indefinitely if they hang.
MAX_CONCURRENT_EXECUTIONS_PER_USER¶
Default: 3
Maximum number of scripts a single user can run simultaneously.
SCREENSHOT_RETENTION_DAYS¶
Default: 7
Number of days to keep screenshots before automatic cleanup.
DATABASE_URL¶
Database connection string.
SQLite (Development):
PostgreSQL (Production):
SECRET_KEY¶
Flask secret key for session security.
Production
Always use a strong, random secret key in production!
Generate one with:
Configuration Files¶
config.py¶
Main configuration file with three environments:
DevelopmentConfig- For local developmentProductionConfig- For production deploymentTestingConfig- For running tests
Select environment:
Production Configuration¶
PostgreSQL Setup¶
-
Install PostgreSQL:
-
Create database:
-
Configure
.env:
Gunicorn Setup¶
-
Install Gunicorn:
-
Run with Gunicorn:
Nginx Reverse Proxy¶
server {
listen 80;
server_name scrapazoid.example.com;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
}
}
Docker Configuration¶
docker-compose.yml¶
version: '3.8'
services:
web:
build: .
ports:
- "5000:5000"
environment:
- FLASK_ENV=production
- DATABASE_URL=postgresql://postgres:password@db/scrapazoid
- SECRET_KEY=${SECRET_KEY}
depends_on:
- db
volumes:
- ./app/static/screenshots:/app/app/static/screenshots
db:
image: postgres:15
environment:
- POSTGRES_DB=scrapazoid
- POSTGRES_PASSWORD=password
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
Security Best Practices¶
- Change default SECRET_KEY
- Use HTTPS in production (SESSION_COOKIE_SECURE=True)
- Restrict database user permissions
- Use environment variables for sensitive data
- Regular backups
- Keep dependencies updated
Performance Tuning¶
Database¶
For high-traffic deployments:
SocketIO¶
For better concurrency:
Monitoring¶
Logging¶
Configure logging in production:
import logging
from logging.handlers import RotatingFileHandler
handler = RotatingFileHandler(
'scrapazoid.log',
maxBytes=10485760, # 10MB
backupCount=10
)
handler.setLevel(logging.INFO)
app.logger.addHandler(handler)