Coder Social home page Coder Social logo

django-sitepush's Introduction

django-sitepush

Redeploy Django projects using management commands

What does it do?

Using Fabric to run a management command on each remote instance to redeploy itself.

The remote command will pull the source code from Git, run all necessary Django management commands, and restart the server.

It's intended for small to medium scale apps.

Why not just write a Fabric script?

It's faster. When the you run everything remotely it only takes about 10 seconds to deploy an instance.

What commands will run?

  • git pull
  • pip install -r requirements.txt
  • syncdb
  • migrate
  • collectstatic
  • restart server (webserver dependent)

Requirements

  • A deployed instance running either:
    • Apache with mod_WSGI
    • GUnicorn
  • Fabric
  • A virtualenv dedicated to the project.
  • A Git hosted repository for the project

Installation

Add the app to your INSTALLED_APPS setting:

INSTALLED_APPS = (
    #...
    'sitepush',
)

Settings

Add the server configuration to your settings file:

DEPLOYS = {
    'default': {
        'HOST': '192.168.0.1',         # IP or domain name
        'USER': 'user',                # User to login with
        'BRANCH': 'master',            # Git branch to pull updates from
        'SETTINGS': 'settings',        # Settings file to use (optional)
        'DIR': '/var/www/myproject/',
        'ENV': 'myvirtualenv',         # virtualenv used in the project
        'WEBSERVER': 'gunicorn',       # webserver - 'apache' or 'gunicorn'

        'PID_FILE': '/tmp/gunicorn.pid',  # Gunicorn pid file path
        'WSGI_FILE': 'deploy/wsgi.py',    # Apache wsgi file path
    },
}

The PID_FILE / WSGI_FILE settings should be set depending on the web server you're using.

BRANCH is optional and defaults to master

Usage

python manage.py deploy_remote default

# Or
python manage.py deploy_remote srv1 srv2 #...'

# Don't install requirements:
python manage.py deploy_remote default --noreqs

# Deploy all remote instances:
python manage.py deploy_remote --all

django-sitepush's People

Contributors

yprez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mechanism

django-sitepush's Issues

Move "git pull" to "deploy_remote"

Updating the repository should be done before running the deploy_local management command.
This will help avoid stale settings and version related bugs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.