mirror of
https://github.com/ae-utbm/sith.git
synced 2025-04-29 12:56:47 +00:00
adapt celery to honcho setup
This commit is contained in:
parent
934d17d9d2
commit
e921a14cd1
@ -10,6 +10,7 @@ DATABASE_URL=sqlite:///db.sqlite3
|
|||||||
|
|
||||||
REDIS_PORT=7963
|
REDIS_PORT=7963
|
||||||
CACHE_URL=redis://127.0.0.1:${REDIS_PORT}/0
|
CACHE_URL=redis://127.0.0.1:${REDIS_PORT}/0
|
||||||
|
BROKER_URL=redis://127.0.0.1:${REDIS_PORT}/1
|
||||||
|
|
||||||
# Used to select which other services to run alongside
|
# Used to select which other services to run alongside
|
||||||
# manage.py, pytest and runserver
|
# manage.py, pytest and runserver
|
||||||
|
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -11,6 +11,7 @@ env:
|
|||||||
SECRET_KEY: notTheRealOne
|
SECRET_KEY: notTheRealOne
|
||||||
DATABASE_URL: sqlite:///db.sqlite3
|
DATABASE_URL: sqlite:///db.sqlite3
|
||||||
CACHE_URL: redis://127.0.0.1:6379/0
|
CACHE_URL: redis://127.0.0.1:6379/0
|
||||||
|
BROKER_URL: redis://127.0.0.1:6379/1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pre-commit:
|
pre-commit:
|
||||||
|
@ -1 +1,2 @@
|
|||||||
redis: redis-server --port $REDIS_PORT
|
redis: redis-server --port $REDIS_PORT
|
||||||
|
celery: uv run celery -A sith worker --beat -l INFO
|
@ -120,7 +120,7 @@ les conflits avec les instances de redis déjà en fonctionnement.
|
|||||||
|
|
||||||
```dotenv
|
```dotenv
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
CACHE_URL=redis://127.0.0.1:${REDIS_PORT}/0
|
CACHE_URL=redis://127.0.0.1:6379/0
|
||||||
```
|
```
|
||||||
|
|
||||||
Si on souhaite configurer redis pour communiquer via un socket :
|
Si on souhaite configurer redis pour communiquer via un socket :
|
||||||
@ -151,7 +151,7 @@ ALTER ROLE sith SET client_encoding TO 'utf8';
|
|||||||
ALTER ROLE sith SET default_transaction_isolation TO 'read committed';
|
ALTER ROLE sith SET default_transaction_isolation TO 'read committed';
|
||||||
ALTER ROLE sith SET timezone TO 'UTC';
|
ALTER ROLE sith SET timezone TO 'UTC';
|
||||||
|
|
||||||
GRANT ALL PRIVILEGES ON DATABASE sith TO SITH;
|
GRANT ALL PRIVILEGES ON DATABASE sith TO sith;
|
||||||
\q
|
\q
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -290,9 +290,15 @@ Pour faire tourner Celery, faites la commande suivante dans
|
|||||||
un terminal à part :
|
un terminal à part :
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
poetry run celery -A sith worker --beat -l INFO
|
uv run celery -A sith worker --beat -l INFO
|
||||||
```
|
```
|
||||||
|
|
||||||
|
!!!note
|
||||||
|
|
||||||
|
Nous utilisons Redis comme broker pour Celery,
|
||||||
|
donc vous devez aussi configurer l'URL du broker,
|
||||||
|
de la même manière que ce qui est décrit plus haut
|
||||||
|
pour Redis.
|
||||||
|
|
||||||
## Mettre à jour la base de données antispam
|
## Mettre à jour la base de données antispam
|
||||||
|
|
||||||
|
@ -100,16 +100,6 @@ cd /mnt/<la_lettre_du_disque>/vos/fichiers/comme/dhab
|
|||||||
Python ne fait pas parti des dépendances puisqu'il est automatiquement
|
Python ne fait pas parti des dépendances puisqu'il est automatiquement
|
||||||
installé par uv.
|
installé par uv.
|
||||||
|
|
||||||
|
|
||||||
Parmi les dépendances installées se trouve redis (que nous utilisons comme cache).
|
|
||||||
Redis est un service qui doit être activé pour être utilisé.
|
|
||||||
Pour cela, effectuez les commandes :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo systemctl start redis
|
|
||||||
sudo systemctl enable redis # si vous voulez que redis démarre automatiquement au boot
|
|
||||||
```
|
|
||||||
|
|
||||||
## Finaliser l'installation
|
## Finaliser l'installation
|
||||||
|
|
||||||
Clonez le projet (depuis votre console WSL, si vous utilisez WSL)
|
Clonez le projet (depuis votre console WSL, si vous utilisez WSL)
|
||||||
|
11
manage.py
11
manage.py
@ -18,10 +18,10 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.utils.autoreload import DJANGO_AUTORELOAD_ENV
|
from django.utils.autoreload import DJANGO_AUTORELOAD_ENV
|
||||||
|
|
||||||
from sith.composer import start_composer, stop_composer
|
from sith.composer import start_composer, stop_composer
|
||||||
from sith.settings import PROCFILE_SERVICE
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
logging.basicConfig(encoding="utf-8", level=logging.INFO)
|
logging.basicConfig(encoding="utf-8", level=logging.INFO)
|
||||||
@ -30,8 +30,11 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
|
|
||||||
if os.environ.get(DJANGO_AUTORELOAD_ENV) is None and PROCFILE_SERVICE is not None:
|
if (
|
||||||
start_composer(PROCFILE_SERVICE)
|
os.environ.get(DJANGO_AUTORELOAD_ENV) is None
|
||||||
_ = atexit.register(stop_composer, procfile=PROCFILE_SERVICE)
|
and settings.PROCFILE_SERVICE is not None
|
||||||
|
):
|
||||||
|
start_composer(settings.PROCFILE_SERVICE)
|
||||||
|
_ = atexit.register(stop_composer, procfile=settings.PROCFILE_SERVICE)
|
||||||
|
|
||||||
execute_from_command_line(sys.argv)
|
execute_from_command_line(sys.argv)
|
||||||
|
@ -47,7 +47,7 @@ from sentry_sdk.integrations.django import DjangoIntegration
|
|||||||
|
|
||||||
from .honeypot import custom_honeypot_error
|
from .honeypot import custom_honeypot_error
|
||||||
|
|
||||||
env = Env()
|
env = Env(expand_vars=True)
|
||||||
env.read_env()
|
env.read_env()
|
||||||
|
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ EMAIL_PORT = env.int("EMAIL_PORT", default=25)
|
|||||||
CELERY_TIMEZONE = TIME_ZONE
|
CELERY_TIMEZONE = TIME_ZONE
|
||||||
CELERY_TASK_TRACK_STARTED = True
|
CELERY_TASK_TRACK_STARTED = True
|
||||||
CELERY_TASK_TIME_LIMIT = 30 * 60
|
CELERY_TASK_TIME_LIMIT = 30 * 60
|
||||||
CElERY_BROKER_URL = env.str("CELERY_BROKER_URL", default="redis://localhost:6379/1")
|
CELERY_BROKER_URL = env.str("BROKER_URL")
|
||||||
CELERY_RESULT_BACKEND = "django-db"
|
CELERY_RESULT_BACKEND = "django-db"
|
||||||
CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"
|
CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user