You are not logged in.
Ok so I developed a web app in python and it worked with the internal server:
if __name__ == '__main__':
app.app.run(debug = True)
with no issue at all. I am now trying to start up a nginx server with uwsgi running on arch linux, here are the config files:
the config.py for my app:
CSRF_ENABLED = True
SECRET_KEY = "you'll-never-know"
PROPAGATE_EXCEPTIONS = True
import os
basedir = os.path.abspath(os.path.dirname(__file__))
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db')
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
/etc/nginx/nginx.conf:
user http;
worker_processes 2;
events {
#worker_connections 1024;
worker_connections 2048;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 70;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;
gzip_vary on;
gzip_comp_level 6;
include /etc/nginx/sites-enabled/*;
}
/etc/nginx/sites-enabled/test.conf
upstream test-server {
server unix:/run/uwsgi/test.sock;
#server 127.0.0.1:3031
}
server {
listen 80;
server_name "";
return 444;
}
server {
server_name 192.xxx.x.xxx;
listen 80;
root /srv/http/test-dir/src/app;
location /static {
alias /srv/http/test-dir/src/app/static;
}
location / {
include /etc/nginx/uwsgi_params;
uwsgi_pass test-server;
}
# rewrite ^ https://$server_name$request_uri? permanent;
}
/etc/uwsgi/emperor.ini
[uwsgi]
emperor = /etc/uwsgi/vassals
#master = true
#plugins = python2
uid = http
gid = http
/etc/uwsgi/vassals
[uwsgi]
chdir = /srv/http/test-dir/src
wsgi-file = run.py
callable = app
processes = 4
threads = 2
offload-threads = 2
stats = 127.0.0.1:9191
max-requests = 5000
enable-threads = true
#master = true
vacuum = true
#socket = 127.0.0.1:3031
socket = /run/uwsgi/test.sock
chmod-socket = 664
harakiri = 60
logto = /var/log/uwsgi/test.log
/var/log/uwsgi/test.log
*** Starting uWSGI 2.0.9 (64bit) on [Wed Mar 25 17:17:53 2015] ***
compiled with version: 4.9.2 20150204 (prerelease) on 28 February 2015 13:34:10
os: Linux-3.19.2-1-ARCH #1 SMP PREEMPT Wed Mar 18 16:21:02 CET 2015
nodename: MyServer
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/bin/uwsgi
chdir() to /srv/http/test-dir/src
your processes number limit is 13370
your memory page size is 4096 bytes
*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /run/uwsgi/test.sock fd 3
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 415360 bytes (405 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1349)
spawned uWSGI worker 1 (pid: 1350, cores: 2)
spawned uWSGI worker 2 (pid: 1351, cores: 2)
spawned 2 offload threads for uWSGI worker 1
spawned uWSGI worker 3 (pid: 1355, cores: 2)
spawned uWSGI worker 4 (pid: 1356, cores: 2)
*** Stats server enabled on 127.0.0.1:9191 fd: 16 ***
spawned 2 offload threads for uWSGI worker 3
spawned 2 offload threads for uWSGI worker 4
spawned 2 offload threads for uWSGI worker 2
-- unavailable modifier requested: 0 --
announcing my loyalty to the Emperor...
-- unavailable modifier requested: 0 --
announcing my loyalty to the Emperor...
As stated I am generating a 502 error when I connect to the servers internal address, this is coming out of the nginx error log:
2015/03/25 17:21:07 [error] 1340#0: *3 upstream prematurely closed connection while reading response header from upstream, client: [me], server: 192.xxx.x.xxx, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/run/uwsgi/test.sock:", host: "192.xxx.x.xxx"
http owns the socket so: ls -ld /run/uwsgi/test.sock
srw-rw-r-- 1 http http 0 Mar 25 17:17 /run/uwsgi/test.sock
I think I have everything on the uwsgi side installed: sudo pacman -Ss uwsgi
community/mod_proxy_uwsgi 2.0.9-3
Apache uWSGI proxy module
community/uwsgi 2.0.9-3 [installed]
A fast, self-healing and developer/sysadmin-friendly application container server coded in pure C
community/uwsgi-plugin-cgi 2.0.9-3
CGI plugin
community/uwsgi-plugin-jvm 2.0.9-3
Plugin for Jvm support
community/uwsgi-plugin-lua51 2.0.9-3
Plugin for Lua support
community/uwsgi-plugin-mono 2.0.9-3
Plugin for mono support
community/uwsgi-plugin-php 2.0.9-3
Plugin for PHP support
community/uwsgi-plugin-psgi 2.0.9-3
Perl psgi plugin
community/uwsgi-plugin-pypy 2.0.9-3
Plugin for PyPy support
community/uwsgi-plugin-python 2.0.9-3
Plugin for Python support
community/uwsgi-plugin-python2 2.0.9-3 [installed]
Plugin for Python2 support
community/uwsgi-plugin-rack 2.0.9-3
Ruby rack plugin
community/uwsgi-plugin-webdav 2.0.9-3
Plugin for webdav support
I had
plugins = python2
enabled [yes this is python2.7] in the main emperor.ini but it didn't do anything, either it is not needed or in the wrong spot. I have read a couple of other things here and at each packages site, not quite sure what I am missing though, but it is something. Thanks.
Last edited by Never (2015-04-01 02:16:33)
Offline
Two things I think helped to solve this
PROPAGATE_EXCEPTIONS = True
in config.py and I removed threading from my vassal ini file the ending uwsgi files looked like this:
/etc/uwsgi/emperor.ini:
[uwsgi]
emperor = /etc/uwsgi/vassals
master = true
plugins = python2
uid = http
gid = http
[/etc/uwsgi/vassals/test.ini:
[uwsgi]
chdir = /srv/http/test_dir/src
wsgi-file = run.py
callable = app
processes = 4
stats = 127.0.0.1:9191
max-requests = 5000
enable-threads = true
vacuum = true
thunder-lock = true
socket = /run/uwsgi/test-sock.sock
chmod-socket = 664
harakiri = 60
logto = /var/log/uwsgi/test.log
Not sure on the
PROPAGATE_EXCEPTIONS = True
but removing the threads option in test.ini and making sure there was a master option in emperor.ini seemed to have solved the issue of sql being tossed around to different treads, or at least it complaining about it and crashing the site out, either or.
Also don't use the uwsgi from this distribution, get it from pip, the distros are broken.
Offline