Re: Using Pyramid with Nginx and uWSGI

1,646 views
Skip to first unread message

Craig Younkins

unread,
Jul 29, 2012, 12:47:22 AM7/29/12
to pylons-...@googlegroups.com
You'll want to follow this tutorial to create your first Pyramid project - http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/project.html#project-narr

When you want to deploy it using uwsgi, follow up to step 7 in this tutorial - http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/tutorials/modwsgi/index.html#modwsgi-tutorial

In your uwsgi ini, 'file' will refer to 'pyramid.wsgi' in the tutorial above, since it will have the wsgi application (callable = 'application')

Hope that helps!

Craig Younkins



On Sat, Jul 28, 2012 at 11:08 PM, Jonah Dahlquist <jonah...@gmail.com> wrote:
Hello, world!

I'm coming into the Python world from a PHP background.  I'm trying to get a working Pyramid application working on my own machine, and I've almost made it.  I have nginx and uWSGI running, and can call a Python script from the browser successfully.  However, lots of research, reading documentation, and even reading through the "starter project" code has failed to make it clear to me how to connect Pyramid to wsgi.  The script looks like this:

def application(env, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    return "Hello universe!"


The INI configuration file for uWSGI is as follows:

[uwsgi]
socket = /tmp/uwsgi.sock
master = true
processes = 4
file = ./app.py
callable = application
daemonize = ./uwsgi.log
pidfile = /tmp/app_process.pid
virtualenv = /home/jonah/.virtualenvs/test


So a request to http://localhost/ in the browser gives me "Hello Universe!".  How can I modify my script/uWSGI configuration to run Pyramid instead?  Thanks for your help.

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pylons-discuss/-/xW1HspiacSYJ.
To post to this group, send email to pylons-...@googlegroups.com.
To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.

Simon Yarde

unread,
Jul 30, 2012, 5:07:44 AM7/30/12
to pylons-...@googlegroups.com
When you have a working pyramid starter project, this might be helpful...

http://projects.unbit.it/uwsgi/wiki/INIFiles

And this..

http://pythonpaste.org/deploy/

You can init like this;

$ uwsgi development.ini

provided you have this line in your .ini

[uwsgi]
paste = config:<absolute_project_path>/development.ini

Alternatively, you can combine the ``ini`` and ``paste`` config action, and remove the need to reference your .ini file twice.

$ uwsgi --ini-paste development.ini

The features above support having combined .ini files, or a single .ini files that configures multiple apps.

ps. You don't need that ``callable`` line because uwsgi reads your paste .ini file and derives from ``use = egg:MyProject``, which is short-hand for ``egg:MyProject#main`` - ``main`` being the callable in your project's ``__init__.py``. I write mine in full as I prefer to have as little implied config as possible.

Jonah Dahlquist

unread,
Aug 13, 2012, 4:31:01 PM8/13/12
to pylons-...@googlegroups.com
Ahh, that first tutorial is great, I wish I had it at the beginning, I would have been up to speed much quicker :)

Jonah Dahlquist

unread,
Aug 13, 2012, 4:32:32 PM8/13/12
to pylons-...@googlegroups.com
Sweet, Simon, that's exactly what I need.  Thanks so much, I'm quite enjoying Python so far, and I have a working starter project now.

Jonathan Vanasco

unread,
Aug 13, 2012, 7:48:41 PM8/13/12
to pylons-discuss
check out my last post in this thread:

http://groups.google.com/group/pylons-discuss/browse_thread/thread/2de9e2661230c999/b93b702bb42b4fc2

might help you get going a bit faster
Reply all
Reply to author
Forward
0 new messages