Coderaemon
Coderaemon

Reputation: 3877

Git Push failing on Openshift?

Trying to git push to Django repo in Openshift getting the folloe error.

remote: Traceback (most recent call last):
remote:   File "/var/lib/openshift/55d9fa9f7628e164d400008b/app-root/runtime/repo/wsgi/myproject/manage.py", line 11, in <module>
remote:     execute_from_command_line(sys.argv)
remote:   File "/var/lib/openshift/55d9fa9f7628e164d400008b/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/__init__.py", line 338, in execute_from_command_line
remote:     utility.execute()
remote:   File "/var/lib/openshift/55d9fa9f7628e164d400008b/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/__init__.py", line 330, in execute
remote:     self.fetch_command(subcommand).run_from_argv(self.argv)
remote:   File "/var/lib/openshift/55d9fa9f7628e164d400008b/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/base.py", line 390, in run_from_argv
remote:     self.execute(*args, **cmd_options)
remote:   File "/var/lib/openshift/55d9fa9f7628e164d400008b/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/core/management/base.py", line 441, in execute
remote:     output = self.handle(*args, **options)
remote:   File "/var/lib/openshift/55d9fa9f7628e164d400008b/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/contrib/staticfiles/management/commands/collectstatic.py", line 168, in handle
remote:     collected = self.collect()
remote:   File "/var/lib/openshift/55d9fa9f7628e164d400008b/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/contrib/staticfiles/management/commands/collectstatic.py", line 98, in collect
remote:     for path, storage in finder.list(self.ignore_patterns):
remote:   File "/var/lib/openshift/55d9fa9f7628e164d400008b/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/contrib/staticfiles/finders.py", line 112, in list
remote:     for path in utils.get_files(storage, ignore_patterns):
remote:   File "/var/lib/openshift/55d9fa9f7628e164d400008b/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/contrib/staticfiles/utils.py", line 28, in get_files
remote:     directories, files = storage.listdir(location)
remote:   File "/var/lib/openshift/55d9fa9f7628e164d400008b/python/virtenv/lib/python2.7/site-packages/Django-1.8-py2.7.egg/django/core/files/storage.py", line 300, in listdir
remote:     for entry in os.listdir(path):
remote: OSError: [Errno 2] No such file or directory: '/Users/ns/ergo/wsgi/static'
remote: -------------------------
remote: Git Post-Receive Result: failure
remote: Activation status: failure
remote: Activation failed for the following gears:
remote: 55d9fa9f7628e164d400008b (Error activating gear: CLIENT_ERROR: Failed to execute action hook 'deploy' for 55d9fa9f7628e164d400008b application ergo
remote: #<IO:0x00000002124290>
remote: #<IO:0x00000002124218>
remote: )
remote: Deployment completed with status: failure
remote: postreceive failed

The OSError directory(/Users/ns/ergo/wsgi/static) does exist I have checked. What is the problem happening ?

Now if I comment following script from deploy hook the git push is successful

python "$OPENSHIFT_REPO_DIR"wsgi/myproject/manage.py collectstatic --noinput

So Static files are causing some issue ?

Upvotes: 0

Views: 265

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58563

The symptoms you see are not strictly the same as the issue it is claimed this duplicates, but the need to set STATIC_ROOT properly as a remedy is.

The error you get suggests you have hard coded the path for STATIC_ROOT to be an actual path on your local MacOS X system. You can't do that, you need to calculate it dynamically.

In the case of OpenShift, you should set STATIC_ROOT as:

STATIC_ROOT = os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'wsgi', 'static')

When collectstatic is run, it should then put static files under the directory wsgi/static within OpenShift. That directory is special and when it exists OpenShift will configure automatically the Apache/mod_wsgi instance to serve up static files from that location at the URL /static. So make sure STATIC_URL is also set to /static.

Upvotes: 1

Related Questions