...
- Créer le fichier du service /etc/init.d/celeryd, identique à ce fichier fichier https://raw.githubusercontent.com/celery/celery/4.23/extra/generic-init.d/celeryd
- chmod 755 /etc/init.d/celeryd
- Créer le fichier /etc/default/celeryd
| Bloc de code |
|---|
CELERYD_NODES="worker1" # Nom du/des worker(s)# Nom du/des worker(s). Ajoutez autant de workers que de tache à executer en paralelle. # exemple : CELERYD_NODES="worker1 worker2 worker3 worker4" CELERYD_NODES="worker1" # Settings de votre Pod DJANGO_SETTINGS_MODULE="pod.settings" # Répertoire source # settings de votre Pod CELERY_BIN="/data/de celery CELERY_BIN="/data/www/%userpod%/.virtualenvs/django_pod/bin/celery" # Application où # répertoire source dese situe celery CELERY_APP="pod.main" # Répertoire du projet Pod (où se trouve manage.py) CELERYD_CHDIR="/data/www/%userpod%/django_projects/podv2" # Options à appliquer en plus sur le comportement du/des # application où se situe celery CELERYD_CHDIR="/data/www/%userpod%/django_projects/podv2" # répertoire du projet Pod (où se trouve manage.py) CELERYD_OPTS="--time-limit=86400 --concurrency=1 --maxtasksperchild=1" # options à appliquer en plus sur le comportement du/des worker(s) CELERYD_LOG_FILE="/var/log/celery/%N.log" # fichier log CELERYD_PID_FILE="/var/run/celery/%N.pid" # fichier pid CELERYD_USER="%userpod%" # utilisateur système utilisant celery CELERYD_GROUP="nginx" # groupe système utilisant celery CELERY_CREATE_DIRS=1 # si celery dispose du droit de création de dossiers CELERYD_LOG_LEVEL="INFO" # niveau d'information qui seront inscrit dans les logs |
...
worker(s)
CELERYD_OPTS="--time-limit=86400 --concurrency=1 --maxtasksperchild=1"
# Fichier log
CELERYD_LOG_FILE="/var/log/celery/%N.log"
# Fichier pid du socket
CELERYD_PID_FILE="/var/run/celery/%N.pid"
# Utilisateur système utilisant celery
CELERYD_USER="%userpod%"
# Groupe système utilisant celery
CELERYD_GROUP="nginx"
# Si celery dispose du droit de création de dossiers
CELERY_CREATE_DIRS=1
# Niveau d'information qui seront inscrit dans les logs
CELERYD_LOG_LEVEL="INFO" |
- Démarrage si nécessaire du service : systemctl start celeryd
| Avertissement |
|---|
# Ayant eu des problèmes de droits sur le répertoire contenant les vidéos (qui peuvent être déposés et par le user nginx et par le user Celery), j'ai ajouté l'utilisateur dans le groupe Nginx et j'ai changé quelques droits : [root ~]# mkdir /var/log/celery [root ~]# mkdir /var/run/celery |
| Avertissement |
Ayant eu des problèmes de droits sur le répertoire contenant les vidéos (qui peuvent être déposés et par le user nginx et par le user Celery), j'ai ajouté l'utilisateur dans le groupe Nginx et j'ai changé quelques droits :[root ~]# usermod -g nginx %userpod% |
...
| Bloc de code | ||||
|---|---|---|---|---|
| ||||
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext_lazy as _
##
# DEBUG mode activation
#
# https://docs.djangoproject.com/en/1.11/ref/settings/#debug
#
# SECURITY WARNING: MUST be set to False when deploying into production.
DEBUG = False
SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxx'
# Droit des fichiers uploadés
FILE_UPLOAD_PERMISSIONS = 0o644
# Permet d'utiliser la mise en ligne fragmentée (qui permet de reprendre la mise en ligne lors de problèmes de connexion)
USE_CHUNKED_UPLOAD = True
##
# A list of strings representing the host/domain names
# that this Django site is allowed to serve.
#
# https://docs.djangoproject.com/en/1.11/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['162.38.xx.xx', 'xxxxx.umontpellier.fr']
##
# A tuple that lists people who get code error notifications
# when DEBUG=False and a view raises an exception.
#
# https://docs.djangoproject.com/fr/1.11/ref/settings/#std:setting-ADMINS
#
ADMINS = (
('Admin Pod', 'xxx.xxx@umontpellier.fr'),
)
##
# A dictionary containing the settings for all databases
# to be used with Django.
#
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
"""
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '/data/www/podtest/django_projects/podv2/db.sqlite',
}
}
"""
# MySQL settings
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'xxx',
'USER': 'xxx',
'PASSWORD': 'xxx',
'HOST': 'xxxxx.umontpellier.fr',
'PORT': '',
'OPTIONS': {'init_command':"SET storage_engine=INNODB, sql_mode='STRICT_TRANS_TABLES', innodb_strict_mode=1;"}
#'OPTIONS': {'init_command':"SET storage_engine=INNODB;"}
}
}
RESTRICT_EDIT_VIDEO_ACCESS_TO_STAFF_ONLY = True
VIDEO_MAX_UPLOAD_SIZE = 4
FILE_ALLOWED_EXTENSIONS = ( 'doc', 'docx', 'odt', 'pdf', 'xls', 'xlsx', 'ods', 'ppt', 'pptx', 'txt', 'html', 'htm', 'vtt', 'srt', 'webm', 'ts', )
IMAGE_ALLOWED_EXTENSIONS = ( 'jpg', 'jpeg', 'bmp', 'png', 'gif', 'tiff', )
FILE_MAX_UPLOAD_SIZE = 20
##
# THIRD PARTY APPS OPTIONNAL
#
USE_PODFILE = True
THIRD_PARTY_APPS = ['live', 'enrichment']
# Nouveaute v2
AUTH_TYPE = (('local', ('local')), ('CAS', 'CAS'))
USE_CAS = True
CAS_VERSION = '3'
CAS_SERVER_URL = 'https://xxx.umontpellier.fr/cas/'
CAS_GATEWAY = False
POPULATE_USER = 'LDAP'
AUTH_CAS_USER_SEARCH = 'user'
CREATE_GROUP_FROM_AFFILIATION = False
AFFILIATION_STAFF = ('faculty', 'employee', 'researcher', 'affiliate')
LDAP_SERVER = {'url': 'xxxxx.umontpellier.fr', 'port': 389, 'use_ssl': False}
AUTH_LDAP_BIND_DN = 'xxx'
AUTH_LDAP_BIND_PASSWORD = 'xxx'
AUTH_LDAP_BASE_DN = 'ou=people,dc=umontpellier,dc=fr'
AUTH_LDAP_USER_SEARCH = (AUTH_LDAP_BASE_DN, "(uid=%(uid)s)")
##
# Internationalization and localization.
#
# https://docs.djangoproject.com/en/1.8/ref/settings/#globalization-i18n-l10n
#
LANGUAGE_CODE = 'fr'
LANGUAGES = (
('fr', 'Fran?§ais'),
('en', 'English')
)
MODELTRANSLATION_DEFAULT_LANGUAGE = 'fr'
MODELTRANSLATION_FALLBACK_LANGUAGES = ('fr', 'en')
##
# A string representing the time zone for this installation.
#
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
#
TIME_ZONE = 'Europe/Paris'
##
# Dynamic files (user managed content: videos, subtitles, documents, etc...)
#
# https://docs.djangoproject.com/en/1.11/ref/settings/#media-url
# https://docs.djangoproject.com/en/1.11/ref/settings/#media-root
#
# WARNING: this folder must have previously been created.
MEDIA_URL = '/media/'
MEDIA_ROOT = '/data/www/%userpod%/media'
FILE_UPLOAD_TEMP_DIR = os.path.join(os.path.sep, 'var', 'tmp')
##
# eMail settings
#
# https://docs.djangoproject.com/en/1.11/ref/settings/#email-host
# https://docs.djangoproject.com/en/1.11/ref/settings/#email-port
# https://docs.djangoproject.com/en/1.11/ref/settings/#default-from-email
#
# username: EMAIL_HOST_USER
# password: EMAIL_HOST_PASSWORD
#
EMAIL_HOST = 'smtp-xxx.umontpellier.fr'
EMAIL_PORT = 25
DEFAULT_FROM_EMAIL = 'xxx.xxx@umontpellier.fr'
# https://docs.djangoproject.com/fr/1.11/ref/settings/#std:setting-SERVER_EMAIL
SERVER_EMAIL = 'xxx.xxx@umontpellier.fr'
MENUBAR_SHOW_STAFF_OWNERS_ONLY = True
HOMEPAGE_SHOWS_RESTRICTED = True
##
# List of Elasticsearch urls, like ['host1', 'host2', ...].
#
# http://elasticutils.readthedocs.io/en/latest/django.html#django.conf.settings.ES_URLS
#
ES_URL = ['http://162.38.xx.xx:9200/']
FFMPEG = '/opt/ffmpeg/ffmpeg/ffmpeg'
FFPROBE = '/opt/ffmpeg/ffmpeg/ffprobe'
# Encode with Celery
CELERY_TO_ENCODE = True
CELERY_NAME = "pod_project"
CELERY_BACKEND = "amqp"
CELERY_BROKER = "amqp://pod:xxxx@162.38.xx.xx//"
# Template Settings
TEMPLATE_VISIBLE_SETTINGS = {
'TITLE_SITE': 'Vidéo - Université de Montpellier',
'TITLE_ETB': 'Université de Montpellier',
'LOGO_SITE': 'custom/um_pod.png',
'LOGO_COMPACT_SITE': 'custom/logo_black_compact.png',
'LOGO_ETB': 'custom/um.png',
'LOGO_PLAYER': 'custom/logo_player.png',
'FOOTER_TEXT': (
'163 rue Auguste Broussonnet',
'34090 Montpellier',
('<a href="https://goo.gl/maps/RHsfxME59Fp"'
' target="_blank">Google maps</a>')
),
'LINK_PLAYER': 'https://www.umontpellier.fr',
'CSS_OVERRIDE': 'custom/um.css',
'FAVICON': 'custom/favicon.png'
}
SUBJECT_CHOICES = ( ('', '-----'), ('info', _('Request more information')), ('request_password', _('Password request for a video')), ('inappropriate_content', _('Report inappropriate content')),
('bug', _('Correction or bug report')), ('other', _('Other (please specify)')) )
# Templates spécifiques UM
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['/data/www/%userpod%/django_projects/podv2/pod/custom/templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
# Local contexts
'pod.main.context_processors.context_settings',
'pod.main.context_processors.context_navbar'
],
},
},
]
DEFAULT_THUMBNAIL = 'custom/default.png'
# Utile pour la reprise de l'existant (adresse de Pod v1 en production)
FROM_URL = 'https://video.umontpellier.fr/media/' |
...
| Bloc de code | ||||||
|---|---|---|---|---|---|---|
| ||||||
[%userpod%@ts-sun-video%userpod%][/]# mkdir /data/www/%userpod%/django_projects/podv2/pod/static/custom |
...
- Réaliser une configuration dans le fichier settings_local.py
| Bloc de code | ||||||
|---|---|---|---|---|---|---|
| ||||||
# Templates spécifiques UM
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['/data/www/%userpod%/django_projects/podv2/pod/custom/templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
# Local contexts
'pod.main.context_processors.context_settings',
'pod.main.context_processors.context_navbar'
],
},
},
] |
...
| Bloc de code | ||
|---|---|---|
| ||
[root]# yum install mod_wsgi [root]# yum install expat-devel [root]# yum install httpd-devel [root]# yum install python36u-mod_wsgi [root]# # ATTENTION: nouveau fichier créé /etc/httpd/conf.modules.d/10-wsgi-python3.6.conf [root]# # Configurer 10-wsgi.conf [root]# # Configurer pod.conf [root]# chmod 755 /data/www/%userpod%/django_projects/podv2/pod/wsgi.py [%userpod%@ts-sun-video%userpod%][/data/www/%userpod%/django_projects/podv2]# pip3 install requests |
...
| Bloc de code | ||||
|---|---|---|---|---|
| ||||
[root]# yum install pcre-devel
[root]# cd /data/www/%userod%/django_projects/podv2/
[root /data/www/%userpod%/django_projects/podv2]# pip3 install uwsgi |
Configuration uWSGI
...
| Bloc de code | ||||
|---|---|---|---|---|
| ||||
[%userpod%@ts-sun-video%userpod% ~]# cd [%userpod%@ts-sun-video%userpod% ~]# source .bashrc [%userpod%@ts-sun-video%userpod% ~]# cd /data/www/%userpod%/django_projects/podv2 [%userpod%@ts-sun-video%userpod% /data/www/%userpod%/django_projects/podv2]# workon django_pod (django_pod) [%userpod%@ts-sun-video%userpod%][/data/www/%userpod%/django_projects/podv2] git pull (django_pod) [%userpod%@ts-sun-video%userpod%][/data/www/%userpod%/django_projects/podv2] python manage.py makemigrations (django_pod) [%userpod%@ts-sun-video%userpod%][/data/www/%userpod%/django_projects/podv2] python manage.py migrate (django_pod) [%userpod%@ts-sun-video%userpod%][/data/www/%userpod%/django_projects/podv2] python manage.py collectstatic |
...
Il est nécessaire de vérifier / réaliser les étapes suivantes à chaque migration :
- la traduction
- la gestion des fichiers statiques, utiles au module H5P
...
| language | bash |
|---|---|
| title | Serveur(s) Pod / Copie de fichiers statiques (compte %userpod%) |
...
- les templates spécifiques (footer.html, 404.html....) doivent, dans certains cas, être modifiés, en cas de changement majeur.
- les autres spécificités qui n'ont pas pu être pris en compte dans le système de répertoire custom.