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:
- Created 4 years ago
- Comments:9 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 usemultiprocess.MultiProcessCollector
from official Python client in my original Flask app. The other app that exposes the metrics uses the same setup for theprometheus_multiproc_dir
environmental variable and hence accesses the metrics from my app.See an example in https://github.com/rycus86/prometheus_flask_exporter/blob/master/examples/uwsgi-lazy-apps/server.py and the setup in https://github.com/rycus86/prometheus_flask_exporter/blob/master/examples/uwsgi-lazy-apps/Dockerfile#L14-L16