We are using uWSGI to deploy several python applications. We would like to use uWSGI to also serve our ruby rack applications. After much struggling to get uWSGI to pick up the application using bundler (eventually I needed to install bundler into the bundle itself), I finally got uWSGI to pick up the application. I am using the following configuration:
[uwsgi]
socket=/tmp/gearbox.sock
master=true
processes=1
post-buffering=4096
env=GEM_PATH=
env=GEM_HOME=/gearbox/vendor/ruby/1.8
uid=vagrant
gid=vagrant
rack=./config.ru
ruby-gc-freq=10
chdir=/gearbox
env=BUNDLE_GEMFILE=/gearbox/Gemfile
My nginx config is fairly straight forward:
location / {
include uwsgi_params;
uwsgi_param SCRIPT_NAME /gearbox/config.ru;
uwsgi_pass unix:///tmp/gearbox.sock;
}
I launch it via: uwsgi -i /apps/uwsgi/gearbox
The startup output looks like this:
[uWSGI] getting INI configuration from /apps/uwsgi/gearbox.ini
*** Starting uWSGI 1.2.3 (64bit) on [Tue May 29 15:46:15 2012] ***
compiled with version: 4.6.3 on 29 May 2012 15:44:06
detected number of CPU cores: 2
current working directory: /gearbox
*** running under screen session 5093.pts-0.precise ***
detected binary path: /usr/local/bin/uwsgi
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uwsgi socket 0 bound to UNIX address /tmp/gearbox.sock fd 3
Python version: 2.7.3 (default, Apr 20 2012, 23:04:22) [GCC 4.6.3]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x17feb20
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
your server socket listen backlog is limited to 100 connections
*** Operational MODE: single process ***
RACK app 0 loaded in 1 seconds at 0x1591 (GC frequency: 10)
spawned uWSGI master process (pid: 10035)
spawned uWSGI worker 1 (pid: 10036, cores: 1)
So, this looks fine to me. However, when I try to connect to the application (via nginx), I receive:
vagrant@precise:~$ curl localhost
<h1>uWSGI Error</h1>Python application not foundvagrant@precise:~$
I’m quite perplexed since it seems that I have this configured right. Any thoughts would be much appreciated.
Thanks
you have missed to set the uwsgi_modifier1 in nginx config (and remove SCRIPT_NAME setting)
If you want to use bundler in the “smart” way, you can simply add:
without messing with GEM_PATH/GEM_HOME environment variables