I have deployed my application on NGINX. And my error.log is full of :
upstream timed out (110: Connection timed out) while reading upstream, client: 10.107.46.176, server: myApp, request: "GET /myApp/Home/index.load HTTP/1.1", upstream: "uwsgi://unix:///tmp/web2py.socket:", host: "myApp.eng.home.com", referrer: "http://myApp.eng.home.com/"
I have a Postgres DB deployed. And this is how the index.htmlpage looks:
<div class="clicks">{{=LOAD(c='Home',f='index',extension='load',ajax=True,timeout=30000,times=3)}}
{{pass}}
</div>
THis is the index.load page:
{{=numHits}}
This is my Home.py controller:
def index():
numHits = db(db.opStatus.id > 0).count()
return dict(numHits=numHits)
THis is working fine with the rocket server, only in NGINX its failing.KIndly help me on this.
web2py.ini
$ cat /etc/uwsgi/web2py.ini
[uwsgi]
socket = /tmp/web2py.socket
pythonpath = /home/www-data/web2py/
mount = /=wsgihandler:application
processes = 4
master = true
harakiri = 60
reload-mercy = 8
cpu-affinity = 1
stats = /tmp/stats.socket
max-requests = 2000
limit-as = 512
reload-on-as = 256
reload-on-rss = 192
uid = www-data
gid = www-data
touch-reload = /home/www-data/web2py/routes.py
cron = 0 0 -1 -1 -1 python /home/www-data/web2py/web2py.py -Q -S myApp -M -R scripts/sessions2trash.py -A -o
no-orphans = true
uwsgi-emperor.conf
/etc/init$ cat uwsgi-emperor.conf
# Emperor uWSGI script
description "uWSGI Emperor"
start on runlevel [2345]
stop on runlevel [06]
##
#remove the comments in the next section to enable static file compression for the welcome app
#in that case, turn on gzip_static on; on /etc/nginx/nginx.conf
##
#pre-start script
# python /home/www-data/web2py/web2py.py -S welcome -R scripts/zip_static_files.py
# chown -R www-data:www-data /home/www-data/web2py/*
#end script
respawn
exec uwsgi --master --die-on-term --emperor /etc/uwsgi --logto /var/log/uwsgi/uwsgi.log
emperor.uwsgi.service
cat /etc/systemd/system/emperor.uwsgi.service
[Unit]
Description = uWSGI Emperor
After = syslog.target
[Service]
ExecStart = /usr/local/bin/uwsgi --ini /etc/uwsgi/web2py.ini
RuntimeDirectory = uwsgi
Restart = always
KillSignal = SIGQUIT
Type = notify
StandardError = syslog
NotifyAccess = all
[Install]
WantedBy = multi-user.target
I am starting the service by : sudo service emperor.uwsgi start
Since my reputation doesn't allow to comment your question, I have to abuse the answering section a little bit hoping not to get any trouble:
Since me deploying my web2py application using NGINX all problems based on a bad configuration of uWSGI. Thus my first advice is to check your uWSGI installation and configuration. Especially check emperor.uwsgi.service, uwsgi/web2py.ini and uwsgi-emperor.conf.
Furthermore, it could be, that you have another web2py installation directory as assumed by default to be "/home/www-data/web2py. In this case you have to adapt nginx/sites-available/web2py.
Finally, check the user who has installed web2py. This user has to be right configured in nginx/nginx.conf
Hope these hints helps you to fix your problem. If not, please post your configuration files as mentioned above.
ADDITIONAL INFORMATION:
Thanks for providing your configuration files. I've compared these to my configuration and it looks fine.
But I'm little confused that you start the emperor manually. In my configuration this is done by the nginx server as configured in /etc/nginx/sites-available/web2py as follows:
Please have special attention to both lines
I marked .socket as special, but can't remember why. Maybe I missed it in the installation script, not sure.
Does this solves your problem?
Best regards Clemens