gunicorn

Flask redirect(url_for) error with gunricorn + nginx

感情迁移 提交于 2020-01-22 09:09:31
问题 I am having a problem with the redirect(url_for) function in my flask app. Any redirect(url_for("index")) line redirects the application from domain.com/app to ip-addr/app , where the ip-addr is my own client machines ip, not the server's. This has gotten me very confused, and I don't know where exactly the issue occurs, as it only happens on the server and not on any local testing. Details: I am using the reverse proxy setup found here http://flask.pocoo.org/snippets/35/. My nginx config is

Flask app logger not working when running within gunicorn

若如初见. 提交于 2020-01-20 15:07:33
问题 I'm trying to save application log messages from a very simple flask app in a log file. While this works flawlessly when I'm running the app with the embedded Flask server, it is not working at all when running within gUnicorn, basically, no application output is redirected neither the log file (the one specified in my Flask app) or to the STDOUT when running gunicorn. That said, this is my Flask app: @app.route('/') def index(): app.logger.debug('Into /!!!!') print 'Will this print?' return

Flask app logger not working when running within gunicorn

限于喜欢 提交于 2020-01-20 15:06:57
问题 I'm trying to save application log messages from a very simple flask app in a log file. While this works flawlessly when I'm running the app with the embedded Flask server, it is not working at all when running within gUnicorn, basically, no application output is redirected neither the log file (the one specified in my Flask app) or to the STDOUT when running gunicorn. That said, this is my Flask app: @app.route('/') def index(): app.logger.debug('Into /!!!!') print 'Will this print?' return

How to get coverage data from a django app when running in gunicorn

别等时光非礼了梦想. 提交于 2020-01-19 07:54:28
问题 How do I get code coverage out of a Django project's view code (and code called by view code)? coverage gunicorn <params> does not show any lines being hit. 回答1: coverage gunicorn <params> does not work, because gunicorn creates worker processes, and the coverage module can't work across forks (basically, creation of new processes). You can use the coverage API, though, for example in the python module that contains your WSGI application: # wsgi_with_coverage.py import atexit import sys

flask+gunicorn+nginx 完成阿里云服务器部署

余生颓废 提交于 2020-01-17 21:41:46
一、登录自己的阿里云账号(地址是 https://account.aliyun.com/login/qr_login.htm?spm=5176.12825654.amxosvpfn.21.3dbd2c4azOfcFt&oauth_callback=https%3A%2F%2Fwww.aliyun.com%2F%3Futm_content%3Dse_1000301881&aly_as=atA-Kxvb) 二、点击右上角控制台查看自己购买的服务器 三、查看自己购买的服务器信息 该服务器的采用的系统是centos+宝塔应用 四、打开Xshell软件(采用ssh远程连接服务器) 五、在Xshell终端输入命令(ssh root@101.132.238.194) 默认情况下账号都是root,为最大权限,@后面接的是服务端的公网地址 六、输入密码,密码为自己阿里云账号密码 连接成功后会有如下提示: 此时就可以远程控制服务端了,不需要经常性打开阿里云控制台页面 七、接下来就是在就是在centos下安装python3了(本人采用的是python3.6版本) 1.下载 wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz 2.安装zlib-devel包(后面安装pip需要用到,这里先下载,后面就不用重复编译) yum

Centos部署Flask项目

荒凉一梦 提交于 2020-01-15 07:16:42
1.安装git: sudo yum install git 2.安装mysql客户端(如果数据库在本机需要安装mysql服务端) wget https://dev.mysql.com/get/mysql-community-client-5.7.25-1.el7.x86_64.rpm rpm -Uvh mysql-community-client-5.7.25-1.el7.x86_64.rpm 如果此处报错则在后面加上--force --nodeps(由于yum安装了旧版本的GPG keys造成的) 3.安装python3 sudo mkdir /usr/local/python3 # 创建安装目录 wget --no-check-certificate https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz #下载Python源文件 # 注意:wget获取https的时候要加上:--no-check-certifica tar -xzvf Python-3.6.4.tgz # 解压缩包 cd Python-3.6.4 # 进入解压目录 sudo ./configure --prefix=/usr/local/python3 # 指定创建的目录 sudo make sudo make install # 编译安装

Heroku Django Gunicorn 'Foreman Start' error

谁说我不能喝 提交于 2020-01-13 06:18:08
问题 I'm working through the Heroku's Django tutorial and I got all the way down to 'Using a different WSIG server'. When I try to use gunicorn I get the following error: requirements.txt Django==1.4.1 distribute==0.6.28 dj-database-url==0.2.1 psycopg2==2.4.5 gunicorn==0.14.6 Procfile web: gunicorn djtut.wsgi -b 0.0.0.0:$PORT (venv) C:\Users\xxxx\Documents\Python\djtut>foreman check valid procfile detected (web) (venv) C:\Users\xxxx\Documents\Python\djtut>foreman start 10:53:05 web.1 | started

Gunicorn logging from multiple workers

被刻印的时光 ゝ 提交于 2020-01-13 02:44:10
问题 I have a flask app that runs in multiple gunicorn sync processes on a server and uses TimedRotatingFileHandler to log to a file from within the flask application in each worker. In retrospect this seems unsafe. Is there a standard way to accomplish this in python (at high volume) without writing my own socket based logging server or similar? How do other people accomplish this? We do use syslog to aggregate across servers to a logging server already but I'd ideally like to persist the log on

gunicorn slower than flask development server

邮差的信 提交于 2020-01-12 11:06:06
问题 My Flask application has a simple feature with a textarea where you input HTML and clicking on a button will strip all the HTML tags and return the text inside the HTML into another textarea, say Text. When I run my application with: app.run(debug=True, host='0.0.0.0', port='8000') it works very fast and smooth. But when I run it with gunicorn like this: gunicorn -w 3 -b 0.0.0.0:8000 --log-file=- myapp.app:app after I click the button 'HtmlToText' it takes too much time to return the text

Connection refused while connecting to upstream when using nginx as reverse proxy

自作多情 提交于 2020-01-12 10:37:29
问题 The setup is as follows: I have a Gunicorn/Django app running on 0.0.0.0:8000 that is accessible via the browser. To serve static files I am running nginx as a reverse proxy. /etc/nginx/nginx.conf is configured to forward requests as follows: server { location /static/ { alias /data/www/; } # Proxying the connections location / { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_redirect off; proxy_pass http://0.0.0.0:8000; } } and my docker