Pyramid with Gunicorn setup

1,697 views
Skip to first unread message

Raj

unread,
Feb 1, 2012, 7:11:54 PM2/1/12
to pylons-discuss
-=Thanks to Ben Bangert for this quick script to get your Pyramid app
up and running with Gunicorn=-

You can easily run Gunicorn with the production.ini (or
development.ini) file you've been using with Waitress (or Paster for
older Pyramid installs), and still start it with `pserve
production.ini`. Just replace the [server:main] section within
production.ini as shown here--> http://gunicorn.org/run.html#paster-serve

Or, if you want to run Gunicorn directly, make a runapp.py file in
your project, dump this into it:
> from paste.deploy import loadapp
>
> application = loadapp('config:production.ini', relative_to='.')
and then you can run: gunicorn runapp

If you'd like to include some additional configurations using the
runapp.py approach, create a config file named gunicorn_config.py (or
whatever you'd like) that looks like this:
> import multiprocessing
>
> try:
> import gevent
> wc = "gevent"
> except ImportError:
> wc = "sync"
>
> bind = "127.0.0.1:5040"
> workers = multiprocessing.cpu_count() * 2 + 1
> worker_class = wc
> timeout = 3
> proc_name = "myapp"
> pidfile = "myapp.pid"

So the full command to start Gunicorn then becomes: gunicorn -c
gunicorn_config.py runapp
This above config file is a random example of some settings you may
have. More can be found here--> http://gunicorn.org/configure.html

Raj

unread,
Feb 1, 2012, 7:21:32 PM2/1/12
to pylons-discuss
Also, make sure you've installed Gunicorn prior to attempting the
above post. Install instructions can be found here--> http://gunicorn.org/install.html
Reply all
Reply to author
Forward
0 new messages