I have a JQuery request for JSON data in my Django app (which started in vitrualenv with uwsgi
and nginx
):
$.getJSON( url, function( data ) {
var obl = "/raj/?raj=" + data.id;
$.getJSON( obl, function( raj_data ) {
...
} );
} );
and corresponding view:
def rcoato(request):
response_data = SprRegion.objects.values('id').get(Q(id=request.GET['region']))
response_data = json.dumps(response_data)
return HttpResponse(response_data, content_type='application/javascript')
It works fine, JSON data returned, but only when I logged in via SSH. I and start my application with:
source virtualenv/bin/activate
uwsgi --xml /home/rino/sites/centre/uwsgi.xml &
When I logged out (with setopt no_hup
and setopt no_checkjobs
), my app works partially - HTML pages are rendering, static files are handling, but requests to /raj/?raj=...
raises Internal Server Error 500.
My nginx.conf
:
server {
listen 8081;
server_name localhost;
access_log /var/log/nginx/nginx_centre_access.log;
error_log /var/log/nginx/nginx_centre_error.log;
location /static {
autoindex on;
alias /home/rino/sites/centre/centre/static/;
}
location / {
uwsgi_pass 127.0.0.1:3031;
include /home/rino/sites/centre/uwsgi_params;
}
}
uwsgi
config:
<uwsgi>
<socket>127.0.0.1:3031</socket>
<processes>5</processes>
<pythonpath>/home/rino/sites/centre</pythonpath>
<chdir>/home/rino/sites/centre/centre</chdir>
<wsgi-file>/home/rino/sites/centre/centre/wsgi.py</wsgi-file>
<pidfile>/tmp/centre-master.pid</pidfile>
<plugin>python3</plugin>
<max-requests>5000</max-requests>
<harakiri>40</harakiri>
<master>true</master>
<threads>2</threads>
</uwsgi>
cat nginx_centre_error.log | tail
after logout and querying request described above:
2014/10/03 07:34:46 [error] 20657#0: *296 connect() failed (111: Connection refused)
while connecting to upstream, client: 176.100.173.177, server: localhost, request: "GET
/settler/ HTTP/1.1", upstream: "uwsgi://127.0.0.1:3031", host: "myhost.com:8081",
referrer: "http://myhost.com/settlersmain/"
2014/10/03 07:56:55 [error] 20657#0: *335 connect() failed (111: Connection refused)
while connecting to upstream, client: 176.100.173.177, server: localhost, request:
"GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:3031", host: "myhost.com:8081"
2014/10/03 08:23:33 [error] 20657#0: *367 open()
Thanks for any help!
UPD: I replace localhost
in server_name
line of nginx.conf
with server IP address, but issue is still present.