I'm in the process of migrating an application to openshift - however I cannot seem to find much (any) documentation on actually getting an application to run in the PaaS. One major problem is knowing I should handle the wsgi.py
file that is default when you create an application - in this case Python3.3.
Here is what I did:
- Create a python3.3 application from the
rhc
command. - Clone the repository.
- edit the
setup.py
and un-comment out the requirement for Django (see link below). - Try the
wsgi.py
suggestion of the below link (changing for the version of python)
How to configure Django on OpenShift?
Now I can see after the push that the django gets pulled in as a requirement (changes in setup.py
). But I cannot work out what should be in the wsgi.py
file - even a basic application that works as a template would be really useful but I simply cannot find one. Using the following for wsgi.py
gives the following error:
#!/usr/bin/python
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'PROJECTNAME.settings'
sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'wsgi',
'PROJECTNAME'))
virtenv = os.environ['APPDIR'] + '/virtenv/'
os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python3.3/site-packages')
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
execfile(virtualenv, dict(__file__=virtualenv))
except IOError:
pass
#
# IMPORTANT: Put any additional includes below this line. If placed above this
# line, it's possible required libraries won't be in your searchable path
#
from django.core.handlers import wsgi
application = wsgi.WSGIHandler()
Here is the error message:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.15 (Red Hat) Server at name-name.rhcloud.com Port 80
Here are the log files I get:
[Thu Jul 03 13:15:59 2014] [error] [client 127.8.250.1] % (self.SETTINGS_MODULE, e)
[Thu Jul 03 13:15:59 2014] [error] [client 127.8.250.1] ImportError: Could not import settings 'name.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named 'name'
80.241.77.253 - - [03/Jul/2014:13:15:59 -0400] "GET /favicon.ico HTTP/1.1" 500 622 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36"
A basic settings.py file would be useful too!