500 internal server error on certain page after a few hours
Posted
by
Brian Leach
on Server Fault
See other posts from Server Fault
or by Brian Leach
Published on 2014-06-11T23:39:59Z
Indexed on
2014/06/12
3:27 UTC
Read the original article
Hit count: 805
I am getting a 500 Internal Server Error on a certain page of my site after a few hours of being up. I restart uWSGI instance with uwsgi --ini /home/metheuser/webapps/ers_portal/ers_portal_uwsgi.ini
and it works again for a few hours.
The rest of the site seems to be working. When I navigate to my_table
, I am directed to the login
page. But, I get the 500
error on my table page on login. I followed the instructions here to set up my nginx and uwsgi configs.
That is, I have ers_portal_nginx.conf
located i my app folder that is symlinked to /etc/nginx/conf.d/
. I start my uWSGI "instance" (not sure what exactly to call it) in a Screen
instance as mentioned above, with the .ini
file located in my app folder
My 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;
}
}
My 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
Relevant parts of my 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
I installed nginx via yum as described here (yesterday) I am using uWSGI installed in my venv via pip I am on CentOS 6
My uwsgi log shows:
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)
When its working, the print statement in the views
"my_table
" route prints into the log file. But not once it stops working.
Any ideas?
© Server Fault or respective owner