Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Django 1.4 with gunicorn example on Openshift DIY
Python Shell
branch: master

Merge pull request #5 from glasslion/master

Update openshift DIY environment variables
latest commit eafeb288a3
@zemanel authored
Failed to load latest commit information.
.openshift Update openshift DIY environment variables
petstore updated openshift settings module to use postgres specific environmen…
static improve Django configuration
templates improve Django configuration
var improve Django configuration
.gitignore improve Django configuration
README.md fixed the README.md again
README_OPENSHIFT.md improve project structure and migrate example to Django 1.4.5
manage.py move django project to repo root
requirements.txt improve project structure and migrate example to Django 1.4.5
settings_localdev.py

README.md

About

A Django 1.4.5 example project for deployment on "Do It Yourself" application type of http://openshift.redhat.com

Example deployment: http://petstore-zemanel.rhcloud.com

Setting up Openshift

Create the Openshift application with a DIY and Postgresql 8.4 cartridge

$ rhc app create djangoexample diy-0.1 postgresql-8.4 --from-code https://github.com/zemanel/openshift-diy-django-example.git

The app should be working out-of-the-box on

http://djangoexample-<YOUR NAMESPACE>.rhcloud.com

Pre deploy stage

On every deployment, the 'deploy' hook script performs the following actions:

  • [re-]creates a python virtual environment on $OPENSHIFT_DATA_DIR/venv and activates it
  • installs a pip requirements file named 'requirements.txt' which is located on the root of the repo. The virtualenv is versioned based on the requirements.txt MD5, to speed up deployments
  • runs the 'syncdb', 'migrate' and 'collectstatic' django commands
  • Pip downloads are cached on the '${OPENSHIFT_TMP_DIR}.pip/cache' folder
  • the 'start' hook script runs gunicorn as a daemon, binded on $OPENSHIFT_INTERNAL_IP:$OPENSHIFT_INTERNAL_PORT, with a pid file written to '${OPENSHIFT_DATA_DIR}gunicorn.pid', which is then used by the 'stop' hook to terminate the gunicorn process
  • there are separated stdout and access logs, outputted to $OPENSHIFT_LOG_DIR

Developing locally

A settings_localdev.py module has out of the box defaults for using local folders and an Sqlite database.

It can easily be used this way:

$ cd djangoexample

$ export DJANGO_SETTINGS_MODULE=settings_localdev

$ python manage.py syncdb

$ python manage.py migrate

$ python manage.py runserver

The settings_localdev.py module approach can be duplicated into another module not checked into source control and further customized, for example.

Contributing

git-flow (https://github.com/nvie/gitflow) is used in the devevelopment process.

To contribute, submit pull requests to the 'develop' branch or a feature branch, which will be tested and then merged.

Something went wrong with that request. Please try again.