Git Product home page Git Product logo

Comments (11)

andrewebdev avatar andrewebdev commented on July 2, 2024

I agree. I'm having the same issue at the moment. The buildout does generate a bin/gunicorn script, as well as a wsgi wrapper. At the same time we also have the standard wsgi.py that django auto generates for a new project.

I'm tried to use all 3 of these in various combinations and configurations in order to run my app with the new gunicorn, with no success.
Documentation or guidance on this topic would be very helpful

from djangorecipe.

reinout avatar reinout commented on July 2, 2024

Apparently I haven't used the new gunicorn yet! Ok, I'll have to dive into this. Some initial thoughts:

  • Django now comes with a wsgi file itself. Probably we ought to copy/use that.
  • The number one thing that djangorecipy does is to set the proper DJANGO_SETTINGS env variable. And bin/gunicorn is generated from the gunicorn egg, not from djangorecipy. Does that mean we need to create a bin/django_gunicorn file or so? Of that it is enought to run bin/gunicorn some/wsgi/file/we/generated? Ideas?

from djangorecipe.

andrewebdev avatar andrewebdev commented on July 2, 2024
  • Agree that we should use django's wsgi file for the sake of consistency
  • I'm a bit torn on entry point. One of my primary reasons for using buildout is the "single point of entry" for your application. So I like the idea of having a bin/run_gunicorn script as my single point of entry. That said, I also like my packages to be as clean and disconnected as possible, so adding a gunicorn configuration inside of djangorecipe, feels like it's adding extra bloat.

from djangorecipe.

andrewebdev avatar andrewebdev commented on July 2, 2024

I've managed to get the latest gunicorn working with the current recipe. It's a tiny bit of a workaround but this works for me.

Firstly note that I'm not using the wsgi or django project skeleton, generated by djangorecipe. I'm using the project skeleton from djangoproject itself. See example buildout, and pay attention to the [python] part. I've added my project directory there as part of the extra-paths, so that it's on the python path, and my the default django wsgi script can be found:

[buildout]
versions = versions
include-site-packages = false
extensions = mr.developer
unzip = true

parts =
    python
    django

auto-checkout = *

eggs =
    pillow
    django
    eventlet
    gunicorn
    psycopg2

[versions]
pillow = 2.6.1
django = 1.7.1
gunicorn = 19.1.1
psycopg2 = 2.5.4

[sources]

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}

# This here is what makes the gunicorn script aware of our app
extra-paths = ${buildout:directory}/<PROJECTNAME>/

[django]
recipe = djangorecipe
project = <PROJECTNAME>
settings = settings
control-script = <PROJECTNAME>
extra-paths = ${buildout:directory}/<PROJECTNAME>/
eggs = ${buildout:eggs}

The above config allows me to run gunicorn as documented: ./bin/gunicorn myapp.wsgi:application
... where, wsgi.py sits in ${buildout:directory}/myapp/myapp/wsgi.py

from djangorecipe.

reinout avatar reinout commented on July 2, 2024

First, I don't use djangorecipe's generated structure myself either :-)

Second, there's one thing weird (to my eye) in your buildout: you don't list your own project as an egg. Do you have a setup.py? If so, just add your project's name to the buildout eggs list and you shouldn't need the extra-paths setting as buildout does the right thing automatically.

Perhaps it works out of the box, then!

from djangorecipe.

andrewebdev avatar andrewebdev commented on July 2, 2024

Problem is that the my primary project in the buildout is not eggified :)
That's a conscious decision, and I dont mind little workarounds like the one above, since it keeps my environment the way I prefer it.

from djangorecipe.

reinout avatar reinout commented on July 2, 2024

Ok, so you're not blocked anymore?

It'll still need fixing, but at least it doesn't need fixing yesterday :-)

from djangorecipe.

andrewebdev avatar andrewebdev commented on July 2, 2024

No, I'm not blocked anymore. If I was I would not expect you to fix my problem :D

from djangorecipe.

reinout avatar reinout commented on July 2, 2024

This should be fixed with release 2.0. Read the changelogs, as I've done quite some cleanup regarding options :-)

Basic idea: add script-entrypoints = gunicorn to your [django] part and you'll get a bin/django_env_gunicorn script that's the same as bin/gunicorn but with the settings env variable set.

As you were using extra-paths for instance, can you check if 2.0 works for you? I've removed some options that seemed to be unused (=only necessary when django wasn't really a proper python package). I might have removed too much :-)

Also feedback regarding changelog/readme and the naming of the bin/django_env_gunicorn (in your case it would be bin/project_env_gunicorn) script is welcome.

from djangorecipe.

andrewebdev avatar andrewebdev commented on July 2, 2024

thx @reinout
Currently busy with other deadlines, but will review the new recipe and gunicorn options soon as I have the time :)

from djangorecipe.

reinout avatar reinout commented on July 2, 2024

No hurry :-)

from djangorecipe.

Related Issues (20)

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.