django_wsgi_deployer

Django WSGI Project Deployer


Keywords
django, wsgi, apache, deployment
License
Other
Install
pip install django_wsgi_deployer==0.3.3

Documentation

django_deployer

Django Projects Deployer. It tries to automate deploying of Django projects/apps into an existing Apache/WSGI server.

You should prepare your apache httpd to serve WSGI scripts from a certain directory (default: /var/www/wsgi). Then you could edit a cfg file like this:

myproject.cfg
[deploy]
name = myproject
src = http://source/of/your/repo/myproject
scm = svn

Quick Usage

# only the first time
pip install django_deployer
# where the wsgi scripts are served
cd /var/www/wsgi
# edit config (see below)
vim myproject.cfg
# deploy
django_wsgi_deploy myproject
# reload apache
systemctl reload httpd

Config keywords

name

The Name of the project or application to deploy (mandatory)

src

The URL of the source code of the project (mandatory).

scm

The source code management used (svn, git, or hg for the moment). Default: 'git'.

scm_clone

The SCM command to clone (aka: checkout) the source tree. Default: 'clone'

dst

Destination directory.

settings

Settings module name. Default: name+'_production'.

url

Relative URL where the project will be deployed Default: name.

build

Build script used to prepare your project (relative to the projects code base). Default: 'build/build.sh'.

deploy_requires

List of python packages needed in deployment. Default: None

deploy_commands

List of django commands to run for deployment (makemigrations, collectstatic, etc.). Default: migrate

wsgi

WSGI script name. Default:'wsgi.py'

allowed_hosts

Hosts allowed to run the deployed project. Default: os.environ['HTTPD_HOST']

secret_key

Secret key to use as SECRET_KEY in django settings. Default: Automatically generated on deploy.

media_root

Where your media files will be stored. Default: os.path.join(HTTPD_MEDIA_BASE, name),

static_root

Where your static files will be collected Default: os.path.join(HTTPD_STATIC_BASE, name)

settings_append

Additional settings that will go into the final settings module (tipically DATABASES definition, etc). Default:

 LOGGING = {
  'version': 1,
  'disable_existing_loggers': False,
  'handlers': {
    'file': {
      'level': 'DEBUG',
      'class': 'logging.FileHandler',
      'filename': '/var/tmp/%(name)-wsgi.log',
    },
  },
  'loggers': {
    '': {
      'handlers': ['file'],
      'level': 'WARNING',
      'propagate': True,
    }
  }
 }

Environment Variables

WSGI_BASE_PATH

Directory were the Django projects will be deployed. Default: /var/www/wsgi

HTTPD_CONF_DIR

Directory were the apache httpd .conf files will be installed. Default: /etc/httpd/locations.d

HTTPD_HOST

Host name under which the Django projects will be authrized to run (ALLOWED_HOSTSsettings). Default: Default hostname.

HTTPD_MEDIA_BASE

Directory under wich the media files will be stored. By default, each project will create a subdirectory under it. Default: /var/www/media

HTTPD_STATIC_BASE

Directory under wich the static files will be collected. By default, each project will create a subdirectory under it. Default: /var/www/static

SECRET_KEY_GEN

Command to generate the SECRET_KEY in Django settings. Default: /usr/bin/pwgen -c -n -y 78 1| /usr/bin/tr -d "%"