question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

uwsgi config "lazy-apps: yes" "should_start_http_server" return False

See original GitHub issue

“UWsgiPrometheusMetrics().should_start_http_server()” returns False when I set uwsgi’s startup parameter “lazy-apps:yes”.

How can I use it when setting “lazy-apps:yes” ? uwsgi config:

uwsgi:
  wsgi: wsgi:app
  http-socket: 0.0.0.0:11010
  processes: 4
  threads: 16
  master: yes
  ignore-write-errors: yes
  ignore-sigpipe: yes
  die-on-term: yes
  wsgi-disable-file-wrapper: yes
  max-requests: 65535
  max-requests-delta: 1024
  log-prefix: uWSGI
  log-date: yes
  log-slow: 10000
  disable-logging: yes
  need-app: true
  reload-mercy: 1
#  lazy-apps: yes

code:

    from prometheus_flask_exporter.multiprocess import UWsgiPrometheusMetrics
    metrics = UWsgiPrometheusMetrics(app)
    metrics.start_http_server(9200, )

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
tlinhartcommented, Aug 7, 2019

I’m a bit late here but anyway. Exposing the metrics endpoint on the main app is fine with lazy-apps. However, when for some reason you need to server the metrics on a different port (e.g. you don’t want to expose them to the world), you can’t do that. That’s exactly my case. In my setup, the app is deployed as a Docker image (nginx -> uWSGI -> Flask app) and I need to run the metrics on a different port so that it’s not exposed to the internet but only to Prometheus running on internal network. The solution I took is to use multiprocess.MultiProcessCollector from official Python client in my original Flask app. The other app that exposes the metrics uses the same setup for the prometheus_multiproc_dir environmental variable and hence accesses the metrics from my app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

uWSGI Options — uWSGI 2.0 documentation - Read the Docs
uWSGI Options¶. This is an automatically generated reference list of the uWSGI options. It is the same output you can get via the...
Read more >
The Art of Graceful Reloading — uWSGI 2.0 documentation
You need reloading for code updates, you need reloading for changes in the uWSGI configuration, you need reloading to reset the state of...
Read more >
Things to know (best practices and “issues”) READ IT - uWSGI
Obviously, never expose a socket speaking the uwsgi protocol to the public ... If this behavior is undesirable for some reason, use the...
Read more >
Configuring uWSGI — uWSGI 2.0 documentation
Configuring uWSGI ¶. uWSGI can be configured using several different methods. All configuration methods may be mixed and matched in the same invocation...
Read more >
uWSGI Documentation
uWSGI natively speaks HTTP, FastCGI, SCGI and its specific protocol named “uwsgi” (yes, wrong naming choice).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found