即使在超时后,gunicorn也不会杀死工人

问题描述 投票:0回答:1

即使在超时后,gunicorn也似乎没有杀死并重新产生工人。

这是我的代码(myapp.py):

 def app(environ, start_response):
 data = b"Hello, World!\n"
 start_response("200 OK", [
     ("Content-Type", "text/plain"),
     ("Content-Length", str(len(data)))
 ])
 return iter([data])

这是我如何触发gunicorn服务器:

gunicorn -t 10 -w 1 --log-level debug myapp:app

这是日志:

[2019-02-22 09:56:15 -0800] [20969] [DEBUG] Current configuration:
  config: None
  bind: ['127.0.0.1:8000']
  backlog: 2048
  workers: 1
  worker_class: sync
  threads: 1
  worker_connections: 1000
  max_requests: 0
  max_requests_jitter: 0
  timeout: 10
  graceful_timeout: 30
  keepalive: 2
  limit_request_line: 4094
  limit_request_fields: 100
  limit_request_field_size: 8190
  reload: False
  reload_engine: auto
  reload_extra_files: []
  spew: False
  check_config: False
  preload_app: False
  sendfile: None
  reuse_port: False
  chdir: /Users/abc/experiments/gnuicorn_test
  daemon: False
  raw_env: []
  pidfile: None
  worker_tmp_dir: None
  user: 501
  group: 20
  umask: 0
  initgroups: False
  tmp_upload_dir: None
  secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
  forwarded_allow_ips: ['127.0.0.1']
  accesslog: None
  disable_redirect_access_to_syslog: False
  access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
  errorlog: -
  loglevel: debug
  capture_output: False
  logger_class: gunicorn.glogging.Logger
  logconfig: None
  logconfig_dict: {}
  syslog_addr: unix:///var/run/syslog
  syslog: False
  syslog_prefix: None
  syslog_facility: user
  enable_stdio_inheritance: False
  statsd_host: None
  statsd_prefix: 
  proc_name: None
  default_proc_name: myapp:app
  pythonpath: None
  paste: None
  on_starting: <function OnStarting.on_starting at 0x1067a6730>
  on_reload: <function OnReload.on_reload at 0x1067a6840>
  when_ready: <function WhenReady.when_ready at 0x1067a6950>
  pre_fork: <function Prefork.pre_fork at 0x1067a6a60>
  post_fork: <function Postfork.post_fork at 0x1067a6b70>
  post_worker_init: <function PostWorkerInit.post_worker_init at 0x1067a6c80>
  worker_int: <function WorkerInt.worker_int at 0x1067a6d90>
  worker_abort: <function WorkerAbort.worker_abort at 0x1067a6ea0>
  pre_exec: <function PreExec.pre_exec at 0x1067b9048>
  pre_request: <function PreRequest.pre_request at 0x1067b9158>
  post_request: <function PostRequest.post_request at 0x1067b91e0>
  child_exit: <function ChildExit.child_exit at 0x1067b92f0>
  worker_exit: <function WorkerExit.worker_exit at 0x1067b9400>
  nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x1067b9510>
  on_exit: <function OnExit.on_exit at 0x1067b9620>
  proxy_protocol: False
  proxy_allow_ips: ['127.0.0.1']
  keyfile: None
  certfile: None
  ssl_version: 2
  cert_reqs: 0
  ca_certs: None
  suppress_ragged_eofs: True
  do_handshake_on_connect: False
  ciphers: TLSv1
  raw_paste_global_conf: []
[2019-02-22 09:56:15 -0800] [20969] [INFO] Starting gunicorn 19.9.0
[2019-02-22 09:56:15 -0800] [20969] [DEBUG] Arbiter booted
[2019-02-22 09:56:15 -0800] [20969] [INFO] Listening at: http://127.0.0.1:8000 (20969)
[2019-02-22 09:56:15 -0800] [20969] [INFO] Using worker: sync
[2019-02-22 09:56:15 -0800] [20972] [INFO] Booting worker with pid: 20972
[2019-02-22 09:56:15 -0800] [20969] [DEBUG] 1 workers
[2019-02-22 09:56:40 -0800] [20972] [DEBUG] GET /
[2019-02-22 09:57:29 -0800] [20972] [DEBUG] GET /
[2019-02-22 09:57:57 -0800] [20972] [DEBUG] GET /
[2019-02-22 09:58:32 -0800] [20972] [DEBUG] GET /
[2019-02-22 10:04:07 -0800] [20972] [DEBUG] GET /

正如您所看到的,超时设置为10秒,但即使在闲置5分钟后工作人员也从未回收。

我在这里错过了什么?非常感谢这方面的任何帮助!

python gunicorn
1个回答
1
投票

好的......只是想通了。 [1]的官方文件说:

沉默超过这么多秒钟的工人被杀死并重新开始。

在这里,silent这个词让我很困惑。我以为GUnicorn会回收那些在timeout所表示的时间段内闲置的工人。实际上,它实际上会杀死接收请求但未在timeout参数提供的时间段内完成的工作人员。

我认为non-responding将是一个更好的术语,而不是silent

[1] http://docs.gunicorn.org/en/stable/settings.html#config

© www.soinside.com 2019 - 2024. All rights reserved.