usnistgov / SpectrumBrowser

ITL
12 stars 11 forks source link

Gunicorn fails "silently" if pid or log directory doesn't exist #182

Closed djanderson closed 9 years ago

djanderson commented 9 years ago

This may be an upstream issue.

If gunicorn is started as a daemon but can't touch its log or pid file, it will fail to start, but will not indicate that in the error log.

dja@spectrum4/opt/SpectrumBrowser$ cd flask/
# /var/run/gunicorn directory does not exist
dja@spectrum4/opt/SpectrumBrowser/flask$ sudo gunicorn --daemon --pid /var/run/gunicorn/gunicorn.pid --log-file error.log --log-level debug flaskr:app
dja@spectrum4/opt/SpectrumBrowser/flask$ cat error.log 
[2015-05-27 10:24:15 +0000] [17781] [DEBUG] Current configuration:
  proxy_protocol: False
  worker_connections: 1000
  syslog: False
  statsd_host: None
  post_fork: <function post_fork at 0x7fd070ca5398>
  pythonpath: None
  enable_stdio_inheritance: False
  worker_class: sync
  ssl_version: 3
  suppress_ragged_eofs: True
  syslog_facility: user
  when_ready: <function when_ready at 0x7fd070ca50c8>
  pre_fork: <function pre_fork at 0x7fd070ca5230>
  cert_reqs: 0
  preload_app: False
  workers: 1
  keepalive: 2
  accesslog: None
  pidfile: /var/run/gunicorn/gunicorn.pid
  worker_tmp_dir: None
  group: 0
  graceful_timeout: 30
  spew: False
  proc_name: None
  umask: 0
  on_reload: <function on_reload at 0x7fd070c9ded8>
  post_worker_init: <function post_worker_init at 0x7fd070ca5500>
  pre_exec: <function pre_exec at 0x7fd070ca5938>
  limit_request_fields: 100
  on_exit: <function on_exit at 0x7fd070cac050>
  config: None
  logconfig: None
  check_config: False
  do_handshake_on_connect: False
  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 0x7fd070ca5aa0>
  post_request: <function post_request at 0x7fd070ca5b90>
  forwarded_allow_ips: ['127.0.0.1']
  worker_int: <function worker_int at 0x7fd070ca5668>
  ca_certs: None
  threads: 1
  max_requests: 0
  chdir: /opt/SpectrumBrowser/flask
  daemon: True
  user: 0
  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 0x7fd070ca5cf8>
  paste: None
  default_proc_name: flaskr:app
  errorlog: error.log
  logger_class: gunicorn.glogging.Logger
  syslog_addr: udp://localhost:514
  syslog_prefix: None
  ciphers: TLSv1
  worker_abort: <function worker_abort at 0x7fd070ca57d0>
  loglevel: debug
  bind: ['127.0.0.1:8000']
  raw_env: []
  reload: False
  limit_request_field_size: 8190
  nworkers_changed: <function nworkers_changed at 0x7fd070ca5e60>
  timeout: 30
  on_starting: <function on_starting at 0x7fd070c9dd70>
  debug: False
  django_settings: None
  tmp_upload_dir: None
  keyfile: None
  backlog: 2048
[2015-05-27 10:24:15 +0000] [17781] [INFO] Starting gunicorn 19.1.1
# When run as not daemon:
dja@spectrum4/opt/SpectrumBrowser/flask$ sudo gunicorn --pid /var/run/gunicorn/gunicorn.pid --log-file error.log --log-level debug flaskr:app

Error: /var/run/gunicorn doesn't exist. Can't create pidfile.
djanderson commented 9 years ago

Killing gunicorn with killproc from /lib/lsb/init-functions is a sufficient workaround for this issue.