mking / flask-uwsgi

Tutorial for setting up Flask with uWSGI + Nginx
271 stars 39 forks source link

Some thing wrong while Creating an Upstart service for uWSGI #4

Open Shellmode opened 9 years ago

Shellmode commented 9 years ago

After creating and configuring the files, when i started the service flask-uwsgi : sudo service flask-uwsgi start

I found some thing wrong with it.

In /var/log/flask-uwsgi/flask-uwsgi.log

''' * Starting uWSGI 2.0.10 (32bit) on [Wed Jun 24 12:52:11 2015] * compiled with version: 4.8.4 on 24 June 2015 12:42:55 os: Linux-3.13.0-55-generic #92-Ubuntu SMP Sun Jun 14 18:33:09 UTC 2015 nodename: iZ94xmv8p4cZ machine: i686 clock source: unix detected number of CPU cores: 1 current working directory: /home/shellmode/foodfun detected binary path: /usr/local/bin/uwsgi !!! no internal routing support, rebuild with pcre support !!! uWSGI running as root, you can use --uid/--gid/--chroot options setgid() to 1000 setuid() to 1000 your processes number limit is 7861 your memory page size is 4096 bytes 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 /var/run/flask-uwsgi/flask-uwsgi.sock fd 6 Python version: 2.7.6 (default, Mar 22 2014, 23:03:14) [GCC 4.8.2] Set PythonHome to venv ImportError: No module named site '''

And to find the status of service flask-uwsgi : sudo service flask-uwsgi status

The result is :

''' flask-uwsgi stop/waiting '''

flask-uwsgi should not be started correctly Is there any ImportError? But in other py file or python shell, i can import module site

Hope for your response, thanks

Shellmode commented 9 years ago

Sorry for my careless, it's just a simple mistake.

Firstly create the virtualenv env virtualenv env

But I change the home in flask-uwsgi.ini from env to venv by mistake.


But i got another problem, after configuring the files, i just got the index page of nginx ( from /var/www/index.html ) just like configure in file flask-uwsgi

When I delete the first server{...}, reload the configure and restart the nginx I got 502 Bad Gateway

I found this line in /var/log/nginx/error.log : ''' 2015/06/24 14:10:46 [crit] 10227#0: *1 connect() to unix:/var/run/flask-uwsgi/flask-uwsgi.sock failed (13: Permission denied) while connecting to upstream, client: xx.xx.xx.xx, server: flask-uwsgi.yy.yy.yy.yy, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/var/run/flask-uwsgi/flask-uwsgi.sock:", host: "aliyun" '''

xx.xx.xx.xx is the client ip yy.yy.yy.yy is the server ip

Then I change the owner of /var/run/flask-uwsgi ( from root to user ), and change the mod of /var/run/flask-uwsgi ( even to 777 ) But nothing worked, I still got 502

So I'm not sure how to fix it, hope for your respons, thanks


Well, I fixed the permission problem, thanks for your tutorial~