Déploiement

Important

Cette documentation ne détaille pas comment sécuriser un serveur. Veuillez vous reporter à la documentation et aux bonnes pratiques correspondant à votre installation et à votre système d'exploitation.

Il y a plusieurs méthodes pour démarrer et servir l'application web FitTrackee et l'application de gestion de la file d'attente de tâches.
Un des moyens est d'utiliser les services systemd et Nginx pour proxy passer à Gunicorn.

Exemples :

Avertissement

À adapter selon la configuration de votre instance et votre système d'exploitation.

  • pour l'application : fittrackee.service

[Unit]
Description=FitTrackee service
After=network.target
After=postgresql.service
After=redis.service
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=<USER>
StandardOutput=journal
StandardError=journal
Environment="APP_SECRET_KEY="
Environment="APP_LOG="
Environment="UPLOAD_FOLDER="
Environment="DATABASE_URL="
Environment="UI_URL="
Environment="EMAIL_URL="
Environment="SENDER_EMAIL="
Environment="REDIS_URL="
Environment="TILE_SERVER_URL="
Environment="STATICMAP_SUBDOMAINS="
Environment="MAP_ATTRIBUTION="
Environment="WEATHER_API_KEY="
Environment="STATICMAP_CACHE_DIR="
WorkingDirectory=/home/<USER>/<FITTRACKEE DIRECTORY>
ExecStart=/home/<USER>/<FITTRACKEE DIRECTORY>/.venv/bin/gunicorn -b 127.0.0.1:5000 "fittrackee:create_app()" --error-logfile /home/<USER>/<FITTRACKEE DIRECTORY>/gunicorn.log
Restart=always

[Install]
WantedBy=multi-user.target

Voir aussi

Pour gérer les fichiers de taille importante, une valeur plus importante pour le timeout peut être configurée.

Voir aussi

Plus d'informations sur le déploiement avec Gunicorn dans sa documentation.

  • pour les workers de la file d'attente : fittrackee_workers.service

[Unit]
Description=FitTrackee task queue service
After=network.target
After=postgresql.service
After=redis.service
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=<USER>
StandardOutput=journal
StandardError=journal
Environment="FLASK_APP=fittrackee"
Environment="APP_SECRET_KEY="
Environment="APP_LOG="
Environment="UPLOAD_FOLDER="
Environment="DATABASE_URL="
Environment="UI_URL="
Environment="EMAIL_URL="
Environment="SENDER_EMAIL="
Environment="REDIS_URL="
Environment="TASKS_TIME_LIMIT="
Environment="STATICMAP_CACHE_DIR="
WorkingDirectory=/home/<USER>/<FITTRACKEE DIRECTORY>
ExecStart=/home/<USER>/<FITTRACKEE DIRECTORY>/.venv/bin/dramatiq fittrackee.tasks:broker --processes=<NUMBER OF PROCESSES> --log-file=<DRAMATIQ_LOG_FILE_PATH>
Restart=always

[Install]
WantedBy=multi-user.target

Note

Commande à adapter pour exécuter les files d'attente séparément.

Voir aussi

Plus d'informations sur l'interface de ligne de commandes de Dramatiq dans sa documentation.

  • Configuration Nginx :

server {
    listen 443 ssl http2;
    server_name example.com;
    ssl_certificate fullchain.pem;
    ssl_certificate_key privkey.pem;

    ## this parameter controls how large of a file can be
    ## uploaded, and defaults to 1MB. If you change the FitTrackee
    ## settings to allow larger uploads, you'll need to change this
    ## setting by uncommenting the line below and setting the size limit
    ## you want. Set to "0" to prevent nginx from checking the
    ## request body size at all
    # client_max_body_size 1m;

    location / {
        proxy_pass http://127.0.0.1:5000;
        proxy_redirect    default;
        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-Host $server_name;
        proxy_set_header  X-Forwarded-Proto $scheme;
    }
}

server {
    listen 80;
    server_name example.com;
    location / {
        return 301 https://example.com$request_uri;
    }
}

Voir aussi

Si besoin, modifier la configuration pour gérer les fichiers de taille importante (cf. client_max_body_size).