Arborescence des pages

Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.
Commentaire: ajout logrotate django/uwsgi

...


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
languagebash
themeMidnight
# Pour CentOS 8, ajoutez

...

 ce yum config-manager :
[root ~]# yum config-manager --set-enabled PowerTools

...

Bloc de code
languagebash
themeMidnight



[root ~]# yum install ImageMagick ImageMagick-devel

...

Utilisé pour l'encodage des vidéos. A À installer sur le serveur d'encodage.

...

Bloc de code
languagepy
themeMidnight
[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
languagebash
titleServeur principal Pod / Compte root
[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
languagebash
titleServeur principal Pod / Compte root
[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-videoroot ~]# 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
languagebash
titleServeur principal Pod / Compte root
[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%@ts-sun-video%userPod%:~/django_projects/pod$ pip3 install -r requirements.txt

Les fichiers relatifs à Celery sont déjà créés dans Pod. L'installation est donc terminée.

...

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
root ~]# usermod -g nginx %userpod%
[
root@ts-sun-video
root ~]# chown %userpod%:nginx /data/www/%userpod%/media -R
[
root@ts-sun-video
root ~]# chmod 755 /data/www/%userpod%/media/ -R
  • Configurer pour que ce service soit démarré lors d'un reboot :
Bloc de code
languagebash
titleMise en service uwsgi-pod (compte root)
[root@ts-sun-videoroot ~]# systemctl daemon-reload
[root@ts-sun-videoroot ~]# systemctl enable celeryd

...

  • 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

??UPDATE `django_site` SET `domain` = 'video.umontpellier.fr', `name` = 'video.umontpellier.fr' WHERE `django_site`.`id` = 1;

...

Avertissement

Pod permet 2 systèmes de barre de progression :

  • Le premier nécessite de recompiler directement les sources d'nginx (je ne vous le recommande pas, cela complique les mises à jour)
  • Le second ne modifie rien dans nginx, et permet en plus de reprendre un téléchargement en cas de coupure réseau (à condition que l'utilisateur ne recharge pas la page) : c'est le mode "CHUNK" que nous préconisons ici. ("USE_CHUNKED_UPLOAD = True" dans settings_local.py)

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
languagetext
titleServeur(s) Pod / Fichier pod_uwsgi.ini
# 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(). 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
languagebash
titleServeur(s) Pod / Compte %userpod%
[%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
languagebash
titleServeur(s) Pod / Compte %userpod%
[%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 --stop /data/www/%userpod%/django_projects/podv2/uwsgi/pod.pid

...

Bloc de code
languagebash
titleMise en service uwsgi-pod (compte root)
[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
title/etc/logrotate.d/django-uwsgi
/data/www/%userpod%/django_projects/podv2/uwsgi/*.log
/data/www/%userpod%/django_projects/podv2/pod/log/*.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

...