Skip to content

zhexiao/pgif

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pgif

Convert video to Gif.

Table of Contents

Requirements

  • Django 1.9.4
  • Django Rest Framework
  • Mysql
  • Gevent
  • ffmpeg
  • Cloudinary

Installation

  • VirtualEnv
    $ virtualenv -p python3 env
  • Django 1.9.4
    $ pip install django
    $ django-admin startproject pgif .
  • Django Rest Framework
    $ pip install djangorestframework
    $ pip install markdown       # Markdown support for the browsable API.
    $ pip install django-filter  # Filtering support
    $ pip install django-rest-swagger # An API documentation generator for Swagger UI and Django REST Framework version 2.3.8+
  • Mysql
    $ sudo apt-get install python3-dev libmysqlclient-dev
    $ pip install mysqlclient
  • Gevent
    $ pip install wheel
    $ pip install setuptools 'cython>=0.23.4' git+git://github.com/gevent/gevent.git#egg=gevent
  • ffmpeg
    $ sudo add-apt-repository ppa:mc3man/trusty-media
    $ sudo apt-get update
    $ sudo apt-get dist-upgrade
    $ sudo apt-get install ffmpeg
  • GIF Clound
    $ pip install cloudinary

Usage

  • Uwsgi Config
[uwsgi]
chdir = /var/www/html/pgif
home = /root/.pgif
module = pgif.wsgi:application

uid = root
gid = www-data

master = true
processes = 5

socket = /tmp/pgif.sock
chmod-socket = 664
vacuum = true
  • Nginx Config
server {
    listen 80;
    server_name localhost;
    location = /favicon.ico {
        access_log off;
        log_not_found off;
    }
    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/pgif.sock;
    }
    
    location /static/ {
      root /var/www/html/pgif/convert;
    }
}
  • Supervisord Config
[program:pgif]
command=uwsgi --ini /var/www/html/pgif/pgif.ini
directory=/var/www/html/pgif
numprocs=1
stdout_logfile=/var/log/pgif_out.log
stderr_logfile=/var/log/pgif_error.log
autostart=true
autorestart=true
startsecs=2
stopwaitsecs=2
killasgroup=true
priority=998
# reread file
$ sudo supervisorctl reread
$ sudo supervisorctl update

# restart
$ sudo service nginx restart
$ sudo supervisorctl restart pgif

Troubleshooting

  • 413 Request Entity Too Large
    edit nginx configuration (/etc/nginx/nginx.conf)
    inside http section
    change client_max_body_size 1m; to client_max_body_size 100M;
  • 502 Bad Gateway
   make sure the UWsgi services runing well
  • Nginx Configuration
server {
    listen 80;
    server_name 127.0.0.1;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /vagrant/pgif/convert;
    }

    location /files/ {
        root /vagrant/files/;
    }

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/pgif.sock;
    }
}

Sass Command

$ sass --watch sass/index.scss:css/index.css --no-cache --sourcemap=none --style compressed