...
- Sources : https://github.com/EsupPortail/podv2
- Documentation : https://podv2.readthedocs.io/ (??cette doc ne sera plus maintenue, se référer plutot au wiki)
Cependant, pour CentOS 7, il a fallu changer de nombreuses commandes. Ci-dessous les étapes d'installation réalisées :
...
Utilisé pour la génération des overviews. A installer sur le serveur d'encodage.
Bloc de code | ||||
---|---|---|---|---|
| ||||
# Pour CentOS 8, ajoutez |
...
ce yum config-manager : [root ~]# yum config-manager --set-enabled PowerTools |
...
Bloc de code | ||||
---|---|---|---|---|
| ||||
[root ~]# yum install ImageMagick ImageMagick-devel |
...
Utilisé pour l'encodage des vidéos. A À installer sur le serveur d'encodage.
...
Bloc de code | ||||
---|---|---|---|---|
| ||||
[root ~]# yum -y install epel-release
[root ~]# rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
[root ~]# # Attention : modification du 0-1 en 0-5 par rapport à la documentation ci-dessus
[root ~]# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
[root ~]# yum repolist
# Pour CentOS 8, ajouter :
[root ~]# yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm -y
[root ~]# yum install --enablerepo=epel ffmpeg ffmpeg-devel
[root ~]# yum install --enablerepo=epel ffmpegthumbnailer |
...
Info |
---|
Si besoin : pour supprimer les anciennes versions d'Erlang : (yum list installed | grep erl | grep -v perl) yum remove 'erlang-*' |
La documentation officielle : https://www.erlang-solutions.com/resources/download.html
...
Bloc de code | ||||
---|---|---|---|---|
| ||||
[root@ts-sun-videoroot ~]# cd [root@ts-sun-videoroot ~]# wget https://github.com/rabbitmq/erlang-rpm/releases/download/v21.2.3/erlang-21.2.3-1.el7.centos.x86_64.rpm [root@ts-sun-videoroot ~]# yum install erlang-21.2.3-1.el7.centos.x86_64.rpm |
...
Bloc de code | ||||
---|---|---|---|---|
| ||||
[root@ts-sun-videoroot ~]# cd [root@ts-sun-videoroot ~]# wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.10/rabbitmq-server-3.7.10-1.el7.noarch.rpm [root@ts-sun-videoroot ~]# rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc [root@ts-sun-videoroot ~]# yum install rabbitmq-server-3.7.10-1.el7.noarch.rpm [root@ts-sun-videoroot ~]# # Démarrage du service la 1° fois [root@ts-sun-video ~root ~]# systemctl start rabbitmq-server [root@ts-sun-videoroot ~]# # Activation des plugins RabbitMQ (utile pour l'interface Web) [root@ts-sun-videoroot ~]# rabbitmq-plugins enable rabbitmq_management |
...
Il est possible d'utiliser une interface Web pour gérer Rabbitmq ; cette interfaçe interface se nomme Rabbitmq management console.
...
Bloc de code | ||||
---|---|---|---|---|
| ||||
[root@ts-sun-videoroot ~]# # On crée un nouvel utilisateur pod qui dispose d'un mot de passe xxxxx [root@ts-sun-videoroot ~]# rabbitmqctl add_user pod xxxxx [root@ts-sun-videoroot ~]# # On donne les droits administrateurs. Commande documentée mais ne fonctionne pas dans mon cas "rabbitmqctl set_admin pod" remplacée par celle ci-dessous [root@ts-sun-videoroot ~]# rabbitmqctl set_user_tags pod administrator [root@ts-sun-videoroot ~]# # Commande documentée mais ne fonctionne pas dans mon cas "abbitmqctlrabbitmqctl clear_admin guest" remplacée par celle ci-dessous [root@ts-sun-videoroot ~]# rabbitmqctl set_permissions -p / pod ".*" ".*" ".*" |
...
Info |
---|
Celery est intégré à Pod dans le fichier requirements.txt à la racine du projet. Pensez à vérifier que vous avez bien installé les prérequis python au passage (n'oubliez pas d'être en environnement virtuel) : (django_pod) %userPod%@ Les fichiers relatifs à Celery sont déjà créés dans Pod. L'installation est donc terminée. |
...
- 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" # # settingsRépertoire source de votre Podcelery 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 # application où se situe celery trouve manage.py) CELERYD_CHDIR="/data/www/%userpod%/django_projects/podv2" # Options à appliquer en plus sur # répertoirele comportement du projet Pod (où se trouve manage.py/des worker(s) CELERYD_OPTS="--time-limit=86400 --concurrency=1 --maxtasksperchild=1" # options à appliquer en plus sur le comportement du/des worker(s)Fichier log CELERYD_LOG_FILE="/var/log/celery/%N.log" # Fichier pid # fichier logdu 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 # 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 |
...
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 [root ~]# usermod -g nginx %userpod% |
- Configurer pour que ce service soit démarré lors d'un reboot :
Bloc de code | ||||
---|---|---|---|---|
| ||||
[root ~]# systemctl daemon-reload
[root ~]# systemctl enable celeryd
|
- Configurer un système de logrotate pour vider régulièrement les logs de Celery, sur le serveur d'encodage. Pour cela, j'ai créé le fichier /etc/logrotate.d/celery avec le contenu suivant :
Bloc de code |
---|
/var/log/celery/*.log {
missingok
notifempty
compress
delaycompress
copytruncate
daily
dateext
rotate 7
size 10M
} |
Configuration Pod v2
Le fichier custom/settings_local.py
La configuration de Pod
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@ts-sun-video ~]# usermod -g nginx %userpod% |
- Configurer pour que ce service soit démarré lors d'un reboot :
Bloc de code | ||||
---|---|---|---|---|
| ||||
[root@ts-sun-video ~]# systemctl daemon-reload
[root@ts-sun-video ~]# systemctl enable celeryd
|
- Configurer un système de logrotate pour vider régulièrement les logs de Celery, sur le serveur d'encodage. Pour cela, j'ai créé le fichier /etc/logrotate.d/celery avec le contenu suivant :
Bloc de code |
---|
/var/log/celery/*.log {
missingok
notifempty
compress
delaycompress
copytruncate
daily
dateext
rotate 7
size 10M
} |
Configuration Pod v2
Le fichier custom/settings_local.py
La configuration de Pod v2 se réalise au travers d'un fichier de configuration, spécifique à chaque établissement, settings_local.py.
...
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' ], }, }, ] |
...
- soit via l'interface d'Administration, module Sites, définir un nom de domaine.
- soit directement en mettant à jour la base de données, table django_site, colonnes domain et name.
...
Astuce |
---|
?? |
...
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 |
...
Avertissement |
---|
Pod permet 2 systèmes de barre de progression :
|
Configuration Nginx
Pour configurer Nginx, je me base sur le fichier fourni par Pod v2, que je copie dans custom et que je personnalise :
...
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 | ||||
---|---|---|---|---|
| ||||
# pod_uwsgi.ini file [uwsgi] # Django-related settings # the base directory (full path) chdir = /data/www/%userpod%/django_projects/podv2 # Django's wsgi file module = pod.wsgi # the virtualenv (full path) home = /data/www/%userpod%/.virtualenvs/django_pod # process-related settings # The master uWSGI process is necessary to gracefully re-spawn and pre-fork workers, consolidate logs, and manage many other features. master = true # maximum number of worker processes processes = 10 # the socket (use the full path to be safe socket = /data/www/%userpod%/django_projects/podv2/uwsgi/podv2.sock chown-socket = %userpod%:nginx # http = :8000 # ... with appropriate permissions - may be needed chmod-socket = 666 # clear environment on exit vacuum = true daemonize = /data/www/%userpod%/django_projects/podv2/uwsgi/uwsgi-pod.log # recommended params by https://www.techatbloomberg.com/blog/configuring-uwsgi-production-deployment/ strict = true ; This option tells uWSGI to fail to start if any parameter in the configuration file isn’t explicitly understood. die-on-term = true ; Shutdown when receiving SIGTERM (default is respawn) need-app = true ; This parameter prevents uWSGI from starting if it is unable to find or load your application module. # Limit process address space (vsz) (in megabytes). # Limits the address space usage of each uWSGI (worker) process using POSIX/UNIX setrlimit(). # Limits the address space usage of each uWSGI (worker) process using POSIX/UNIX setrlimit(). For example, limit-as 256 will disallow uWSGI processes to grow over 256MB of address space. Address space is the virtual memory a process has access to. It does not correspond to physical memory. Read and understand this page before enabling this option: http://en.wikipedia.org/wiki/Virtual_memory # limit-as = 5120 # max-requests = 5000 |
Démarrage manuel des workers uWSGI
...
. For example, limit-as 256 will disallow uWSGI processes to grow over 256MB of address space. Address space is the virtual memory a process has access to. It does not correspond to physical memory. Read and understand this page before enabling this option: http://en.wikipedia.org/wiki/Virtual_memory
# limit-as = 5120
# max-requests = 5000
|
Démarrage manuel des workers uWSGI
Il faut lancer la commande uwsgi, en pointant vers le bon fichier pod_uwsgi.ini, via l'environnement django_pod. Cela donne :
Bloc de code | ||||
---|---|---|---|---|
| ||||
[%userpod%]# cd
[%userpod% /home/%userpod%]# source .bashrc
[%userpod% /home/%userpod%]# cd /data/www/%userpod%/django_projects/podv2
[%userpod% /data/www/%userpod%/django_projects/podv2]# workon django_pod
(django_pod) [%userpod%][/data/www/%userpod%/django_projects/podv2]# /usr/bin/uwsgi --ini /data/www/%userpod%/django_projects/podv2/pod/custom/pod_uwsgi.ini --enable-threads --uid %userpod% --gid nginx --pidfile /data/www/%userpod%/django_projects/podv2/uwsgi/pod.pid |
Arrêt manuel des workers uWSGI
Bloc de code | ||||
---|---|---|---|---|
| ||||
[%userpod%]# cd [%userpod% /home/%userpod%]# source .bashrc [%userpod% /home/%userpod%]# cd /data/www/%userpod%/django_projects/podv2 [%userpod% /data/www/%userpod%/django_projects/podv2]# workon django_pod (django_pod) [%userpod%][/data/www/%userpod%/django_projects/podv2]# /usr/bin/uwsgi --inistop /data/www/%userpod%/django_projects/podv2/uwsgi/pod/custom/pod_uwsgi.ini --enable-threads --uid %userpod% --gid nginx --pidfile /data/www/%userpod%/django_projects/podv2/uwsgi/pod.pid.pid |
Mise en place d'un service
Pour éviter de démarrer / arrêter manuellement le système de workers uWSGI, il est nécessaire de créer un service.
Ce service s'appelle uwsgi-pod.service, positionné dans /etc/systemd/system/.
Voici le contenu de ce fichier :Arrêt manuel des workers uWSGI
Bloc de code | |||||
---|---|---|---|---|---|
| |||||
# [Unit] Description=Pod uWSGI app After=syslog.target [Service] ExecStartPre=-/usr/bin/bash -c 'export WORKON_HOME=[%userpod%]# cd [%userpod% /home/%userpod%]# source .bashrc [%userpod% /home/%userpod%]# cd /data/www/%userpod%/django_projects/podv2 [%userpod%.virtualenvs; export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.6; cd /data/www/%userpod%/django_projects/podv2]# workon django_pod (django_pod) [%userpod%][; source /usr/bin/virtualenvwrapper.sh; workon django_pod;' ExecStart=/usr/bin/bash -c '/usr/bin/uwsgi --ini /data/www/%userpod%/django_projects/podv2]# /usrpod/bincustom/pod_uwsgi.ini --enable-threads --uid %userpod% --gid nginx --stoppidfile /data/www/%userpod%/django_projects/podv2/uwsgi/pod.pid |
Mise en place d'un service
Pour éviter de démarrer / arrêter manuellement le système de workers uWSGI, il est nécessaire de créer un service.
Ce service s'appelle uwsgi-pod.service, positionné dans /etc/systemd/system/.
Voici le contenu de ce fichier :
'
ExecStop=/usr/bin/uwsgi --stop /data/www/%userpod%/django_projects/podv2/uwsgi/pod.pid
User=%userpod%
Group=nginx
Restart=on-failure
Type=notify
TimeoutStopSec=15
KillSignal=SIGQUIT
RemainAfterExit=yes
StandardError=syslog
NotifyAccess=all
StartLimitBurst=0
[Install]
WantedBy=multi-user.target
limit-as=512 |
Pensez à créer le répertoire /var/run/podv2, avec les droits adéquats pour pod:nginx.
Configurer pour que ce service soit démarré lors d'un reboot :
Bloc de code | ||||
---|---|---|---|---|
| ||||
[root ~]# systemctl daemon-reload
[root ~]# systemctl enable uwsgi-pod.service
|
Rotation des logs
Configurer un système de logrotate pour vider régulièrement les logs de django et uwsgi. Pour cela, j'ai créé le fichier /etc/logrotate.d/django-uwsgi avec le contenu suivant :
Bloc de code | ||||
---|---|---|---|---|
| ||||
Bloc de code | ||||
| ||||
# [Unit] Description=Pod uWSGI app After=syslog.target [Service] ExecStartPre=-/usr/bin/bash -c 'export WORKON_HOME=/data/www/%userpod%/.virtualenvs; export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.6; cd /data/www/%userpod%/django_projects/podv2; source /usr/bin/virtualenvwrapper.sh; workon django_pod;' ExecStart=/usr/bin/bash -c '/usr/bin/uwsgi --ini /data/www/%userpod%/django_projects/podv2/pod/custom/pod_uwsgi.ini --enable-threads --uid %userpod% --gid nginx --pidfile /data/www/%userpod%/django_projects/podv2/uwsgi/pod*.pid' ExecStop=/usr/bin/uwsgi --stop log /data/www/%userpod%/django_projects/podv2/pod/uwsgilog/pod*.pid User=%userpod% Group=nginx Restart=on-failure Type=notify TimeoutStopSec=15 KillSignal=SIGQUIT RemainAfterExit=yes StandardError=syslog NotifyAccess=all StartLimitBurst=0 [Install] WantedBy=multi-user.target limit-as=512 |
Pensez à créer le répertoire /var/run/podv2, avec les droits adéquats pour pod:nginx.
Configurer pour que ce service soit démarré lors d'un reboot :
...
language | bash |
---|---|
title | Mise en service uwsgi-pod (compte root) |
...
log {
su %userpod% nginx
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 0640 %userpod% nginx
sharedscripts
postrotate
systemctl restart uwsgi-pod >/dev/null 2>&1
endscript
}
|
Puis lancez la commande suivante pour vérifier que ca fonctionne :
logrotate -d /etc/logrotate.d/django-uwsgi
Migrations de Pod v2
Migration v2.0.4 vers v2.1.0
...
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.