Code Repositories xandikos / a0226f3
Make sure prometheus_multiproc_dir is set early enough. Jelmer Vernooń≥ 3 years ago
3 changed file(s) with 19 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
1717 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
1818 # MA 02110-1301, USA.
1919
20 import sys
21
22 from prometheus_client import multiprocess
23 from prometheus_client import CollectorRegistry, make_wsgi_app
24 from xandikos.prometheus import DEFAULT_PROMETHEUS_DIR
25
2620 import optparse
21 import os
2722 import sys
2823
2924 from xandikos import __version__
25 from xandikos.prometheus import DEFAULT_PROMETHEUS_DIR
3026 parser = optparse.OptionParser(version='.'.join(map(str, __version__)))
3127 parser.add_option("-l", "--listen_address", dest="listen_address",
3228 default="localhost",
4036 help="Path to prometheus statistics.")
4137
4238 options, args = parser.parse_args()
39
40 from prometheus_client import multiprocess
41 from prometheus_client import CollectorRegistry, make_wsgi_app
4342 from wsgiref.simple_server import make_server
4443
4544 registry = CollectorRegistry()
11 socket = 127.0.0.1:8001
22 uid = xandikos
33 gid = xandikos
4 exec-as-root = install -u xandikos -g xandikos -d /run/xandikos
4 exec-as-root = install -o %(uid) -g %(gid) -d /run/xandikos
55 master = true
66 cheaper = 2
77 processes = 4
2121
2222 import os
2323
24 from xandikos.web import XandikosApp
25
26 from prometheus_client import multiprocess
27 from prometheus_client import CollectorRegistry, make_wsgi_app
24 # Do this before anything imports prometheus_client; it has side-effects,
25 # and needs to have ${prometheus_multiproc_dir} set.
26 os.environ['prometheus_multiproc_dir'] = ''
27 import prometheus_client
2828
2929
30 from xandikos.web import XandikosApp
3031 app = XandikosApp(
3132 path=os.environ['XANDIKOSPATH'],
3233 current_user_principal=os.environ.get('CURRENT_USER_PRINCIPAL', '/user/'))
3334
3435 if os.environ.get('ENABLE_PROMETHEUS', '1') == '1':
35 from xandikos.prometheus import PrometheusRedirector, DEFAULT_PROMETHEUS_DIR
36 prometheus_dir = os.environ.get('PROMETHEUS_DIR', DEFAULT_PROMETHEUS_DIR)
36 from prometheus_client import multiprocess
37 from prometheus_client import CollectorRegistry
38 from xandikos.prometheus import DEFAULT_PROMETHEUS_DIR, PrometheusRedirector
39 os.environ['prometheus_multiproc_dir'] = os.environ.get(
40 'PROMETHEUS_DIR', DEFAULT_PROMETHEUS_DIR)
41 os.makedirs(os.environ['prometheus_multiproc_dir'])
42
3743 registry = CollectorRegistry()
38 multiprocess.MultiProcessCollector(registry, os.prometheus_dir)
44 multiprocess.MultiProcessCollector(registry)
3945 app_with_metrics = PrometheusRedirector(app, registry)