我正在为由10个微服务组成的nginx / supersvisord / gunicorn / flask应用程序设置dev / prod环境。每个环境都在1个GCE实例上运行
一切都在prod环境和开发环境的7个应用程序上正常工作
但其他3个应用程序没有启动:curl on(本地)地址只是等待(但没有说连接被拒绝),并且工作人员每2分钟重新启动并重新启动(根据gunicorn -t
参数)。
此外,当我使用supervisord stop
终止这些应用程序时,这些过程可能需要一分钟才能关闭(功能应用程序的进程立即关闭)。
如何解决这个问题?
两种环境的文件和文件夹的应用程序代码,监督配置和所有者权限相同。
我使用的是Python 3.5,gunicorn 19.6.0,supervisord 3.3.1。
以下是应用程序的示例supervisord配置(所有应用程序的配置相同):
[program:platform]
command = <virtualenv_dir>/bin/gunicorn main:app -w 4 -b 127.0.0.1:8000 -t 120 --log-level=DEBUG
directory = <app_dir>
user = <username>
这是来自supervisord日志的调试(再次,gunicorn配置输出对于所有应用程序是相同的,无论是否工作):
[2016-08-18 12:57:39 +0000] [32197] [DEBUG] Current configuration:
ciphers: TLSv1
errorlog: -
preload_app: False
max_requests_jitter: 0
daemon: False
limit_request_field_size: 8190
keepalive: 2
django_settings: None
enable_stdio_inheritance: False
statsd_host: None
paste: None
logconfig: None
pre_request: <function PreRequest.pre_request at 0x7f1b398149d8>
accesslog: None
proxy_protocol: False
logger_class: gunicorn.glogging.Logger
on_reload: <function OnReload.on_reload at 0x7f1b39809c80>
post_fork: <function Postfork.post_fork at 0x7f1b398141e0>
worker_int: <function WorkerInt.worker_int at 0x7f1b39814510>
threads: 1
proxy_allow_ips: ['127.0.0.1']
syslog: False
syslog_prefix: None
pre_exec: <function PreExec.pre_exec at 0x7f1b39814840>
spew: False
forwarded_allow_ips: ['127.0.0.1']
default_proc_name: main:app
worker_abort: <function WorkerAbort.worker_abort at 0x7f1b398146a8>
reload: False
cert_reqs: 0
workers: 4
tmp_upload_dir: None
backlog: 2048
proc_name: None
worker_exit: <function WorkerExit.worker_exit at 0x7f1b39814c80>
limit_request_line: 4094
sendfile: None
loglevel: DEBUG
capture_output: False
group: 1004
ca_certs: None
statsd_prefix:
when_ready: <function WhenReady.when_ready at 0x7f1b39809e18>
umask: 0
secure_scheme_headers: {'X-FORWARDED-SSL': 'on', 'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https'}
syslog_facility: user
bind: ['127.0.0.1:8000']
chdir: /var/www/rokit/platform
worker_tmp_dir: None
pythonpath: None
limit_request_fields: 100
suppress_ragged_eofs: True
worker_connections: 1000
max_requests: 0
config: None
do_handshake_on_connect: False
pidfile: None
on_starting: <function OnStarting.on_starting at 0x7f1b39809ae8>
pre_fork: <function Prefork.pre_fork at 0x7f1b39814048>
access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
syslog_addr: udp://localhost:514
on_exit: <function OnExit.on_exit at 0x7f1b39819048>
worker_class: sync
keyfile: None
raw_env: []
post_worker_init: <function PostWorkerInit.post_worker_init at 0x7f1b39814378>
check_config: False
certfile: None
ssl_version: 3
graceful_timeout: 30
post_request: <function PostRequest.post_request at 0x7f1b39814ae8>
user: 1004
timeout: 120
nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7f1b39814e18>
[2016-08-18 12:57:39 +0000] [32197] [INFO] Starting gunicorn 19.6.0
[2016-08-18 12:57:39 +0000] [32197] [DEBUG] Arbiter booted
[2016-08-18 12:57:39 +0000] [32197] [INFO] Listening at: http://127.0.0.1:8000 (32197)
[2016-08-18 12:57:39 +0000] [32197] [INFO] Using worker: sync
[2016-08-18 12:57:39 +0000] [32200] [INFO] Booting worker with pid: 32200
[2016-08-18 12:57:39 +0000] [32202] [INFO] Booting worker with pid: 32202
[2016-08-18 12:57:39 +0000] [32203] [INFO] Booting worker with pid: 32203
[2016-08-18 12:57:39 +0000] [32204] [INFO] Booting worker with pid: 32204
[2016-08-18 12:57:39 +0000] [32197] [DEBUG] 4 workers
[2016-08-18 12:59:39 +0000] [32197] [CRITICAL] WORKER TIMEOUT (pid:32200)
[2016-08-18 12:59:39 +0000] [32200] [INFO] Worker exiting (pid: 32200)
[2016-08-18 12:59:39 +0000] [32197] [CRITICAL] WORKER TIMEOUT (pid:32202)
[2016-08-18 12:59:39 +0000] [32202] [INFO] Worker exiting (pid: 32202)
[2016-08-18 12:59:39 +0000] [32197] [CRITICAL] WORKER TIMEOUT (pid:32203)
[2016-08-18 12:59:39 +0000] [32203] [INFO] Worker exiting (pid: 32203)
[2016-08-18 12:59:39 +0000] [32197] [CRITICAL] WORKER TIMEOUT (pid:32204)
[2016-08-18 12:59:39 +0000] [32204] [INFO] Worker exiting (pid: 32204)
[2016-08-18 12:59:39 +0000] [32289] [INFO] Booting worker with pid: 32289
[2016-08-18 12:59:40 +0000] [32197] [DEBUG] 1 workers
[2016-08-18 12:59:40 +0000] [32290] [INFO] Booting worker with pid: 32290
[2016-08-18 12:59:40 +0000] [32292] [INFO] Booting worker with pid: 32292
[2016-08-18 12:59:40 +0000] [32293] [INFO] Booting worker with pid: 32293
[2016-08-18 12:59:40 +0000] [32197] [DEBUG] 4 workers
[2016-08-18 13:01:40 +0000] [32197] [CRITICAL] WORKER TIMEOUT (pid:32289)