I'm currently looking after a django project running on a Cpanel server that appears to be building up "Script timed out before returning headers: index.wsgi" after a few days of running. I'm monitoring this at the moment to try and find out what may be causing the issue but since the project is for a time limited event I'm limited as to what I can dabble with at the moment. The setup is Apache (as prefork I think)/Nginx proxy with mod_wsgi 3.3 running a django 1.3 project. Server is also serving PHP sites. Once the following errors start to build up I've found a restart of Nginx is all that is needed, so during the event, I'm manually monitoring the apache error log and if I see these errors I restart Nginx.
I should mention that I use an .htaccess rewrite rule to redirect to my index.wsgi in public_html rather than have that set in a vhost.conf as the latter tends to be a bit obscurely located on Cpanel and, as you can see, I've been adding eg logging middleware to my index.wsgi file, etc to try and identify the issues. I'd be very appreciative if anyone can let me know of any issues they can see with any of the following. Clearly I'm no sys-op so am fairly bumbling my way through/learning on the job with all this. Cheers, Nick Lo ----------------------------------------- Apache error log: ----------------------------------------- [Sat Sep 03 09:51:25 2011] [error] [client 67.195.114.48] Script timed out before returning headers: index.wsgi [Sat Sep 03 09:51:44 2011] [error] [client 95.108.151.244] Script timed out before returning headers: index.wsgi [Sat Sep 03 09:51:48 2011] [error] [client 93.158.148.30] Script timed out before returning headers: index.wsgi [Sat Sep 03 09:52:02 2011] [error] [client 66.249.72.213] Script timed out before returning headers: index.wsgi ----------------------------------------- ----------------------------------------- In: /usr/local/apache/conf/userdata/std/2/<user>/<usersdomain>.org/ vhost.conf: ----------------------------------------- <IfModule mod_wsgi.c> # See the link below for an introduction about this mod_wsgi config. # http://groups.google.com/group/modwsgi/browse_thread/thread/60cb0ec3041ac1bc/2c547b701c4d74aa # WSGIDaemonProcess <user> processes=7 threads=1 display-name=%{GROUP} WSGIDaemonProcess <user> threads=1 processes=1 stack-size=524288 display-name=%{GROUP} maximum-requests=500 inactivity-timeout=30 WSGIProcessGroup <user> WSGIApplicationGroup %{GLOBAL} </IfModule> ----------------------------------------- ----------------------------------------- In public_html/index.wsgi: ----------------------------------------- import os, sys HOME_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(HOME_DIR + '/djangoware') sys.path.append(HOME_DIR + '/djangoware/lib') os.environ['DJANGO_SETTINGS_MODULE'] = 'index.settings' os.environ['PYTHON_EGG_CACHE'] = HOME_DIR + "/djangoware/index/ cache/" import django.core.handlers.wsgi #application = django.core.handlers.wsgi.WSGIHandler() import pprint class LoggingMiddleware: def __init__(self, application): self.__application = application def __call__(self, environ, start_response): errors = environ['wsgi.errors'] pprint.pprint(('REQUEST', environ), stream=errors) def _start_response(status, headers, *args): pprint.pprint(('RESPONSE', status, headers), stream=errors) return start_response(status, headers, *args) return self.__application(environ, _start_response) application = LoggingMiddleware(django.core.handlers.wsgi.WSGIHandler()) ----------------------------------------- ----------------------------------------- Nginx.conf: ----------------------------------------- user nobody; # no need for more workers in the proxy mode worker_processes 2; error_log /var/log/nginx/error.log info; worker_rlimit_nofile 20480; events { worker_connections 5120; # increase for busier servers use epoll; # you should use epoll here for Linux kernels 2.6.x } http { server_name_in_redirect off; server_names_hash_max_size 10240; server_names_hash_bucket_size 1024; include mime.types; default_type application/octet-stream; server_tokens off; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 120 120; proxy_read_timeout 120; gzip on; gzip_vary on; gzip_disable "MSIE [1-6]\."; gzip_proxied any; gzip_http_version 1.1; gzip_min_length 1000; gzip_comp_level 6; gzip_buffers 16 8k; # You can remove image/png image/x-icon image/gif image/jpeg if you have slow CPU gzip_types text/plain text/xml text/css application/x-javascript application/xml image/png image/x-icon image/gif image/jpeg application/xml+rss text/javascript application/atom+xml; ignore_invalid_headers on; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; reset_timedout_connection on; connection_pool_size 256; client_header_buffer_size 256k; large_client_header_buffers 4 256k; client_max_body_size 200M; client_body_buffer_size 128k; request_pool_size 32k; output_buffers 4 32k; postpone_output 1460; proxy_temp_path /tmp/nginx_proxy/; client_body_in_file_only on; log_format bytes_log "$msec $bytes_sent ."; include "/etc/nginx/vhosts/*"; } ----------------------------------------- -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
