Flask网络应用程序的某个页面在几个小时后会关闭

时间:2014-06-11 23:45:18

标签: python nginx flask uwsgi

我正在CentOS盒子上托管一个带有nginx和uWSGI的Flask应用程序。几个小时后,我的一个页面下了一个500 internal server error你看到从我下面的配置中跳出来的东西吗?

我的ers_portal_nginx.conf

server {
    listen      80;
    server_name www.mydomain.com;

    location / { try_files $uri @app; }
    location @app {
        include uwsgi_params;
        uwsgi_pass unix:/home/metheuser/webapps/ers_portal/run_web_uwsgi.sock;
    }
}

我的ers_portal_uwsgi.ini

[uwsgi]
#user info
uid = metheuser
gid = ers_group

#application's base folder
base = /home/metheuser/webapps/ers_portal

#python module to import
app = run_web
module = %(app)

home = %(base)/ers_portal_venv
pythonpath = %(base)

#socket file's location
socket = /home/metheuser/webapps/ers_portal/%n.sock

#permissions for the socket file
chmod-socket    = 666

#uwsgi varible only, does not relate to your flask application
callable = app

#location of log files
logto = /home/metheuser/webapps/ers_portal/logs/%n.log

我的views.py

的相关部分
data_modification_time = None
data = None
def reload_data():
    global data_modification_time, data, sites, column_names
    filename = '/home/metheuser/webapps/ers_portal/app/static/' + ec.dd_filename
    mtime = os.stat(filename).st_mtime
    if data_modification_time != mtime:
        data_modification_time = mtime
        with open(filename) as f:
            data = pickle.load(f)
    return data

@a bunch of authentication stuff...

@app.route('/')
@app.route('/index')
def index():
    return render_template("index.html",
                           title = 'Main',)

@app.route('/login', methods = ['GET', 'POST'])
def login():
    login stuff...

@app.route('/my_table')
@login_required
def my_table():
    print 'trying to access data table...'
    data = reload_data()
    return render_template("my_table.html",
                           title = "Rundata Viewer",
                           sts = sites,
                           cn = column_names,
                           data = data) #  dictionary of data

我通过yum安装了nginx(昨天) 我通过pip使用安装在我的venv中的uWSGI 我在CentOS 6上 我的所有设置都与here非常相似,这意味着所有配置都在我的app文件夹中,并且/etc/nginx/nginx.conf符号链接到。

我的uwsgi日志显示:

Wed Jun 11 17:20:01 2014 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 287] during GET /whm-server-status (127.0.0.1)
IOError: write error
[pid: 9586|app: 0|req: 135/135] 127.0.0.1 () {24 vars in 292 bytes} [Wed Jun 11 17:20:01 2014] GET /whm-server-status => generated 0 bytes in 3 msecs (HTTP/1.0 404) 2 headers in 0 bytes (0 switches on core 0)

当它工作时,viewsmy_table”路由中的print语句将打印到日志文件中。但不是一旦它停止工作。

有什么想法吗?

0 个答案:

没有答案