gunicorn

Flask+Nginx+gunicorn部署

纵然是瞬间 提交于 2020-01-11 05:55:37
为了大四校内实习,用写一个微信小程序,所以决定用Flask写/注册登录接口 写完之后就准备要部署到服务器上 首先查看服务器上有无Python3,我的服务器上本来就有Python2.7和Python3.5,然后根据 https://www.cnblogs.com/Yanfang20180701/p/10588087.html 将默认Python版本改为3.5. 查看有无pip3 没有的话apt-get install pip3, 安装缺少的python包,如果提示 Unable to locate package python3-pip3 就查看 https://www.cnblogs.com/jp1021/p/9885890.html 如果提示pip3不是最新版本 最好不要更新(我更了之后就无法安装Python包了) 安装完后,安装mysql 根据 https://blog.csdn.net/james_nan/article/details/82053430 然后将自己的Flask项目上传到服务器 比如/root这个目录下 项目名称是login 所以整个结构是/root/login/ 然后执行 gunicorn -w 4 -b 127.0.0.1:5000 app:app 第一个app就是引导用的 python 入口文件名称(不包括后缀/模块名)第二个app就是 Flask

Handling all website one-off root static files like favicon.ico reliably and elegantly?

霸气de小男生 提交于 2020-01-06 07:34:06
问题 Perhaps I'm missing something (I hope I am!), but it seems awfully clunky to have to have deal with the one-off root website files requested by the browser, such as favicon.ico and things like apple-touch-icon-precomposed.png (on the iPad). Right now, I'm getting a 500 server error whenever I encounter one of these for which I'm not explicitly serving up a file. My questions: Is there an up-to-date list of all such files for all major browsers that my webapp should be handling? As a failsafe,

Gunicorn gevent worker logging issues

亡梦爱人 提交于 2020-01-06 07:21:42
问题 I have a gunicorn server running with 1 worker. I user the logging module during the request. None of them appear in stdout. I know that gevent workers monkey patch all so I would assume any loggin done during the request should appear on the mainthread stdout. The app parse to gunicorn is the application wsgi from django. gunicorn -c gunicorn.py core.wsgi:application In gunicorn.py I have: bind = '0.0.0.0:8080' backlog = 2048 workers = 1 worker_class = 'gevent' worker_connections = 1000

Gunicorn gevent worker logging issues

a 夏天 提交于 2020-01-06 07:20:06
问题 I have a gunicorn server running with 1 worker. I user the logging module during the request. None of them appear in stdout. I know that gevent workers monkey patch all so I would assume any loggin done during the request should appear on the mainthread stdout. The app parse to gunicorn is the application wsgi from django. gunicorn -c gunicorn.py core.wsgi:application In gunicorn.py I have: bind = '0.0.0.0:8080' backlog = 2048 workers = 1 worker_class = 'gevent' worker_connections = 1000

Django AJAX requests during regular request not going through

落爺英雄遲暮 提交于 2020-01-04 09:17:11
问题 I have a Django site with a login webpage. When the login form on the page is submitted, it executes the login view, which runs a function inside it that takes a long time to process (30 seconds or so). So in order to show progress to the client during login, as soon as the form is submitted, a JS function on the login page starts making AJAX POST requests to the server (to a poll_state view), which returns the state of the login. It then updates the html of the login page to show the state

Django: 400 Error with Debug=False and ALLOWED_HOSTS=[“*”]

ⅰ亾dé卋堺 提交于 2020-01-04 02:15:09
问题 I'm trying to run a relatively simple Django server on Python 3.5.3 on an Ubuntu DigitalOcean droplet. I'm using a Gunicorn server with nginx. The server runs fine when DEBUG=True in settings.py . But when I set it to False , I get a 400 error when trying to visit the page. I tried setting ALLOWED_HOSTS = ['*'] , but I still get the same error. I've looked on a lot of forums and many questions on SO but none of the solutions have worked. EDIT Gunicorn logs from startup: [2016-09-13 00:02:01

Static Files not being displayed in Production

点点圈 提交于 2020-01-03 04:40:15
问题 EDITED TO SHOW UPDATED CONFIGURATION No static files are being shown in Production. Files are showing correctly in Development settings.py BASE_DIR = os.path.dirname(__file__) STATIC_ROOT = '/opt/soundshelter/static/' print "Base Dir: " + BASE_DIR #this returns /opt/soundshelter/soundshelter/soundshelter print "Static Root: " + STATIC_ROOT #this returns /opt/soundshelter/static/ STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) #/opt/soundshelter/soundshelter

Can one small portion of an app use gevent, or does the whole app have to switch over?

喜夏-厌秋 提交于 2020-01-02 18:19:26
问题 I have an already written large app using standard python threading constructs such as threads, queues, normal sockets, and multiprocessing. It has a web frontend implemented using Flask. I want to expose a certain part of the apps state in real time using websockets. I looked into Flask-Sockets which uses gevent and gunicorn. Does my whole app have to use the event-driven model, or can I leave the rest of the blocking code the way it is? (Basic tests seem to having both blocking and evented

Heroku app runs locally but gets H12 timeout error (uses a package)

末鹿安然 提交于 2020-01-02 07:32:38
问题 Similar questions have been asked but the H12 seems to be caused by many things and none of the answers apply here. I have built python apps with heroku before but now I'm using a package structure per Miguel Grinberg's Flask Mega-Tutorial and I can't figure out what's wrong. My app is python / Flask / SQLAlchemy with a Heroku postgres database. The app fully works locally. When I push to Heroku, I get an H12. Here is my app structure: rootappdirectory\ app\ static\ templates\ __init__.py

UnicodeEncodeError [Python3/Gunicorn/Nginx/Django]

我怕爱的太早我们不能终老 提交于 2020-01-02 05:41:43
问题 Solved This error happened when I follow the instruction in here. I set Unit file. I understood that LAN env valuable doens't transfer properly and it used default ascii. You can fix this problem with adding one line in unit file. It was a really long journey to find out.... [service] Environment="LANG=en_US.UTF-8" I didn't have any problem when I set my environment with mod_wsgi and Apache2. I just had to add " export LANG='en_US.UTF-8' export LC_ALL='en_US.UTF-8' " in /etc/apache2/envars