Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Django 1.4 with gunicorn example on Openshift DIY

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .openshift
Octocat-spinner-32 petstore
Octocat-spinner-32 static
Octocat-spinner-32 templates
Octocat-spinner-32 var
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 README_OPENSHIFT.md
Octocat-spinner-32 manage.py
Octocat-spinner-32 requirements.txt
Octocat-spinner-32 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.