server production version - gunicorn
This commit is contained in:
@@ -48,12 +48,34 @@ python seed.py
|
||||
|
||||
## Running
|
||||
|
||||
### Development
|
||||
|
||||
```bash
|
||||
python app.py
|
||||
```
|
||||
|
||||
The server starts on `http://localhost:5000`.
|
||||
|
||||
### Production
|
||||
|
||||
```bash
|
||||
# Install dependencies (includes gunicorn)
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Run with gunicorn
|
||||
gunicorn -c gunicorn.conf.py "app:create_app()"
|
||||
```
|
||||
|
||||
Gunicorn starts on `http://0.0.0.0:8000` with `cpu * 2 + 1` workers.
|
||||
|
||||
#### systemd service
|
||||
|
||||
```bash
|
||||
sudo cp yggdrasil.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now yggdrasil
|
||||
```
|
||||
|
||||
| Route | Description |
|
||||
|---|---|
|
||||
| `/sensors` | Dashboard with interactive chart and data table |
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import os
|
||||
|
||||
bind = "0.0.0.0:8000"
|
||||
workers = min(os.cpu_count() * 2 + 1, 9)
|
||||
timeout = 30
|
||||
keepalive = 5
|
||||
errorlog = "-"
|
||||
accesslog = "-"
|
||||
loglevel = "info"
|
||||
@@ -1,3 +1,4 @@
|
||||
flask>=3.0
|
||||
flask-sqlalchemy>=3.1
|
||||
alembic>=1.13
|
||||
alembic>=1.13
|
||||
gunicorn>=22.0
|
||||
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=Yggdrasil Sensor API
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=mateusz
|
||||
Group=mateusz
|
||||
WorkingDirectory=/home/mateusz/prog/yggdrasil/server
|
||||
ExecStart=/home/mateusz/prog/yggdrasil/server/.venv/bin/gunicorn -c gunicorn.conf.py "app:create_app()"
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user