繁体   English   中英

nginx,gunicorn和django超时

[英]nginx, gunicorn and django timing out

我很混乱! 我进行了所有设置,我的网站运行了两天,然后今天突然停止了工作。 我唯一更改的是昨天我试图提供PHP文件,因此我安装了PHP和uwsgi。 已经很晚了,我没有意识到自己在做什么。 它来自以下网站: http : //uwsgi-docs.readthedocs.org/en/latest/PHP.html

# Add ppa with libphp5-embed package
sudo add-apt-repository ppa:l-mierzwa/lucid-php5
# Update to use package from ppa
sudo apt-get update
# Install needed dependencies
sudo apt-get install php5-dev libphp5-embed libonig-dev libqdbm-dev
# Compile uWSGI PHP plugin
python uwsgiconfig --plugin plugins/php

但没有更改任何设置。 即使这样做了,一切仍然很好。 但是第二天,我的网站就没有加载。

我尝试了一些无效的方法。 在我的设置中:

ALLOWED_HOSTS = ['*']


在我的gunicorn.sh中,将TIMEOUT设置为60。 但是,当我尝试访问我的网站(lewischi.com)时,什至没有任何反应。 但是当我访问http://127.0.0.1:8000时 ,我确实看到工作人员在做事,并收到404错误。

Using the URLconf defined in django_project.urls, 
Django tried these URL patterns, in this order: 


我不确定发生了什么! nginx错误日志不是很有用,但是访问日志似乎更有用。

从我的nginx-access.log(它起作用,然后停止工作):

50.156.86.221 - - [25/Sep/2015:00:25:43 -0700] "GET /codeWindow.html 
HTTP/1.1" 200 2081 "http://lewischi.com/" "Mozilla/5.0 (Windows NT 6.1; WOW64) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36"
50.156.86.221 - - [25/Sep/2015:00:25:58 -0700] "GET /test.jpg HTTP/1.1" 
404 208 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 
(KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36"
192.168.2.6 - - [25/Sep/2015:16:42:19 -0700] "GET / HTTP/1.1" 200 9596 "-" "-"
192.168.2.6 - - [25/Sep/2015:17:24:44 -0700] "GET / HTTP/1.1" 200 9596 "-" "-"
192.168.2.6 - - [25/Sep/2015:23:28:51 -0700] "GET / HTTP/1.1" 200 9596 "-" "-"
192.168.2.6 - - [25/Sep/2015:23:29:02 -0700] "GET / HTTP/1.1" 200 9596 "-" "-"


从我的主管日志文件中:

supervisor: couldn't exec /home/lewischi/projects/active/django_project/gunicorn.sh: ENOEXEC   
supervisor: child process was not spawned

任何帮助将不胜感激!!!! 我觉得我应该只卸载uwsgi。 我不想破坏任何东西,所以在弄乱之前我要征求意见。


我对此很陌生,所以我可能忽略了一些显而易见的事情。 我的gunicorn调试模式输出:

    “Starting ”djangotut” as lewischi”
[2015-09-26 17:50:28 +0000] [2316] [DEBUG] Current configuration:
  proxy_protocol: False
  worker_connections: 1000
  statsd_host: None
  max_requests_jitter: 0
  post_fork: <function post_fork at 0x7faf049ec848>
  pythonpath: None
  enable_stdio_inheritance: False
  worker_class: sync
  ssl_version: 3
  suppress_ragged_eofs: True
  syslog: False
  syslog_facility: user
  when_ready: <function when_ready at 0x7faf049ec578>
  pre_fork: <function pre_fork at 0x7faf049ec6e0>
  cert_reqs: 0
  preload_app: False
  keepalive: 2
  accesslog: None
  group: 1000
  graceful_timeout: 30
  do_handshake_on_connect: False
  spew: False
  workers: 3
  proc_name: ”djangotut”
  sendfile: True
  pidfile: None
  umask: 0
  on_reload: <function on_reload at 0x7faf049ec410>
  pre_exec: <function pre_exec at 0x7faf049ecde8>
  worker_tmp_dir: None
  post_worker_init: <function post_worker_init at 0x7faf049ec9b0>
  limit_request_fields: 100
  on_exit: <function on_exit at 0x7faf049f2500>
  config: None
  secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
  proxy_allow_ips: ['127.0.0.1']
  pre_request: <function pre_request at 0x7faf049ecf50>
  post_request: <function post_request at 0x7faf049f20c8>
  user: 1000
  forwarded_allow_ips: ['127.0.0.1']
  worker_int: <function worker_int at 0x7faf049ecb18>
  threads: 1
  max_requests: 1
  limit_request_line: 4094
  access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
  certfile: None
  worker_exit: <function worker_exit at 0x7faf049f2230>
  chdir: /home/lewischi/projects/active/django_project
  paste: None
  default_proc_name: django_project.wsgi:application
  errorlog: -
  loglevel: DEBUG
  logconfig: None
  syslog_addr: udp://localhost:514
  syslog_prefix: None
  daemon: False
  ciphers: TLSv1
  on_starting: <function on_starting at 0x7faf049ec2a8>
  worker_abort: <function worker_abort at 0x7faf049ecc80>
  bind: ['0.0.0.0:8000']
  raw_env: []
  reload: False
  check_config: False
  limit_request_field_size: 8190
  nworkers_changed: <function nworkers_changed at 0x7faf049f2398>
  timeout: 60
  ca_certs: None
  django_settings: None
  tmp_upload_dir: None
  keyfile: None
  backlog: 2048
  logger_class: gunicorn.glogging.Logger
  statsd_prefix: 
[2015-09-26 17:50:28 +0000] [2316] [INFO] Starting gunicorn 19.3.0
[2015-09-26 17:50:28 +0000] [2316] [DEBUG] Arbiter booted
[2015-09-26 17:50:28 +0000] [2316] [INFO] Listening at: http://0.0.0.0:8000 (2316)
[2015-09-26 17:50:28 +0000] [2316] [INFO] Using worker: sync
[2015-09-26 17:50:28 +0000] [2327] [INFO] Booting worker with pid: 2327
[2015-09-26 17:50:28 +0000] [2328] [INFO] Booting worker with pid: 2328
[2015-09-26 17:50:28 +0000] [2329] [INFO] Booting worker with pid: 2329
[2015-09-26 17:50:29 +0000] [2316] [DEBUG] 3 workers
[2015-09-26 17:50:30 +0000] [2316] [DEBUG] 3 workers

问题不在于管理者本身,在处理Nginx,Gunicorn和Django时通常要考虑的几件事:

  1. 确保运行应用程序进程的用户(至少1个非root用户,不包括默认情况下为以下用户创建的用户:例如Nginx,Postgresql。随着堆栈的更改)具有实现其目标的正确权限和所有权。
  2. 当添加其他应用将你的筹码,你应该首先检查它在默认情况下运行的端口,将其更改为防止端口冲突,记住内部和外部端口之间的差别,因为你使用的Nginx作为代理Gunicorn( 这是造成大多数超时的原因(在深夜工作中几次发生),您可以使用Nginx作为代理服务器,并为每个应用程序创建许多具有不同唯一内部端口的应用程序。

使用提供给主管的错误日志,您似乎正在与没有足够权限或所有权的用户一起运行gunicorn.sh,或使用错误的命令执行。

请提供与您的应用相关的主管配置文件。

更新 :似乎他的IP地址已更改。

啊没关系。 谢谢你的时间。 原来,我的IP地址发生了某些变化,这本不应该发生的。。。菜鸟错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM