CransWiki:

Mediadrop

C'est accessible ici : https://mediadrop.crans.org

Après avoir découvert ce serveur et tenté accidentellement une maj du service via un git pull qui s'est évidemment mal passée, il a bien fallu que je (Chirac) découvre comment fonctionnait la bête.

Ça se passe dans le /opt/mediadrop. C'est servi par apache, moyennant un fichier de conf spécifique dans /etc/apache2/conf.d/mediadrop, à adapter éventuellement en cas de changement de conf.

Installation (dans mon cas j'ai tout réinstallé en conservant seulement la db)

Il faut cloner le dépot git (ou puller pour maj) dans /opt/mediadrop/sousdossier qui va bien.

À la racine (/opt/mediadrop/) vous trouverez un fichier deployment.ini, un fichier mediacore.wsgi, un dossier mediadrop (qui est le dépôt git que j'ai cloné), un dossier data et un dossier venv.

Inutile de dire que ceux-ci sont importants.

Pour installer, il vaut mieux suivre ce tuto : http://mediadrop.net/docs010/install/index.html

Pour mettre à jour

Ensuite, il vaut mieux suivre ce tuto : http://mediadrop.net/docs010/install/upgrade.html

Pour réparer/réinstaller le mediadrop, j'ai utilisé les 2.

/!\ Gros piège : à chaque fois que le tuto mentionne mediacore, il faut le remplacer par mediadrop (ex : paster make-config MediaCore deployment.ini -> MediaDrop deployment.ini)

Explication : ils ont changé la nomenclature mais ils ont oublié de maj le tuto, peut être que ce sera le cas quand vous lirez ces lignes.

Utiliser nginx

On va utiliser nginx pour servir le contenu statique, puis nginx enverra les requête pour de contenu dynamique à uwsgi, un serveur wsgi comme gunicorn. Je n'ai pas réussi a faire fonctionner gunicorn, et de toute façon uwsgi est normalement plus performant et simple à configurer, et mieux docummenté (voir man uwsgi et man uwsgi_python).

  1. Ajouter les groupes nginx et uwsgi à la machine dans bcfg2 puis faire un run de bcfg2

  2. Éditer deployment.ini et y ajouter :

    • [uwsgi]
      plugin = python
      chdir = /opt/mediadrop
      virtualenv = /opt/mediadrop/venv
      wsgi-file = /opt/mediadrop/mediacore.wsgi
  3. Éditer mediacore.wsgi et supprimer la ligne if __name__.startswith('_mod_wsgi_'): (penser à désindenter ce qui se trouver dans le bloc). En effet, seul le mod_wsgi d'apache met __name__ à _mod_wsgi_.

  4. Exécuter samir@mediadrop $ sudo ln -s /opt/mediadrop/deployment.ini /etc/uwsgi/apps-enabled/mediadrop.ini

  5. Lancer un sudo service uwsgi restart normalement, la socket unix /run/uwsgi/app/mediadrop/socket doit être créé par uwsgi.

  6. Ajouter un site mediadrop à nginx, par exemple avec le contenu suivant :

    • # Configure our MediaDrop App for NGINX+UWSGI
      server {
          listen       mediadrop.adm.crans.org:80;
          server_name  mediadrop.crans.org videos.crans.org video.crans.org;
      
          # Important: This setting will define maximum upload size, so make
          # sure it is sane for your purposes! For example, if you have a
          # 300MB upload limit in MediaDrop, people will say "Yay! I can upload
          # my 300MB video!" However, if this setting is set to 10MB, then no
          # one will be able to upload videos over 10MB and people will not
          # like you very much.
          client_max_body_size 1500M;
      
          # Define NGINX Static File Paths
          #
          # First, define our default document root for static file serving.
          # NGINX configuration uses inheritance, so defining our base root here
          # will assign it to every other location{} declaration unless an
          # alternate path is specified. Also, any files that reside in the root will
          # of course not need to be defined as they are included. An example
          # would be /crossdomain.xml
          #
          # * Note: The ~* used in our location block regexes activates
          # case insensitive matching on the paths. This may or may not be
          # what you are after in your configuration. If you want /path and /Path
          # to be different paths, then just use ~ not ~*
          #
          # See the NGINX docs on Location  regex matching for more details:
          # http://wiki.nginx.org/HttpCoreModule#location
      
          root /opt/mediadrop/mediadrop/mediadrop/public/;
      
          # And now we define the rest of our static locations below
          location ~* ^/(appearance)/ {
                  root /opt/mediadrop/data/ ;
                  break;
          }
      
          # All media and podcast images
          location ~* ^(/images\/media|images\/podcasts) {
                  root /opt/mediadrop/data/ ;
                  break;
          }
      
          # Our standard public file paths
          location ~* ^/(styles|scripts|images)/ {
                  expires max;
                  add_header Cache-Control "public";
                  break;
          }
      
          # Configure NGINX XSendfile.
          # We use an alias here instead of root so the path info
          # __mediacore_serve__ is stripped off.
          # Note: __mediacore_serve__ is defined in MediaDrop as the path to serve NGINX files from.
          # Note: We define this as an "internal" location to prevent it from
          # being served directly to end users.
          location /__mediacore_serve__ {
                  alias /opt/mediadrop/data/media/;
                  internal;
          }
      
          # Declare our default location to pass through to our app
          # This will match any request not defined above and pass it to uWSGI
          # Note: The uwsgi_pass directive must use the same socket that was
          # defined in your deployment.ini [uwsgi] block.
          # Note: Make sure that you pass in SCRIPT_NAME = '' otherwise uWSGI
          # will raise a keyError when loading MediaDrop.
          location / {
                  uwsgi_pass      unix:///run/uwsgi/app/mediadrop/socket;
                  include         uwsgi_params;
                  uwsgi_param     SCRIPT_NAME '';
          }
      
          set_real_ip_from 10.231.136.0/24;
          set_real_ip_from 2a01:240:fe3d:c804::/64;
          real_ip_header P-Real-Ip;
      }
  7. Enjoy !

Problèmes rencontrés

CransWiki: CransNostalgie/CransTechnique/ServicesMineurs/Mediadrop (dernière édition le 2021-09-24 14:06:17 par WikiShirenn)