From 476a170f2399138846a76c8e8eed61bc7b37c184 Mon Sep 17 00:00:00 2001 From: Joakim Nordling Date: Tue, 17 Nov 2020 14:36:09 +0200 Subject: [PATCH 1/2] Make it possible to pass address from environment variable --- uwsgitop | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/uwsgitop b/uwsgitop index 0d7a899..211616b 100755 --- a/uwsgitop +++ b/uwsgitop @@ -1,6 +1,7 @@ #!/usr/bin/env python import argparse +import os try: import urllib2 except ImportError: @@ -69,9 +70,13 @@ def merge_worker_with_cores(workers, rps_per_worker, cores, rps_per_core): workers[:] = new_workers def parse_args(): + default_address = os.environ.get("UWSGITOP_ADDRESS") + address_nargs = "?" if default_address else None + parser = argparse.ArgumentParser() parser.add_argument('--frequency', type=int, default=1, help='Refresh frequency in seconds') - parser.add_argument('address', help='uWSGI stats socket or address') + parser.add_argument('address', help='uWSGI stats socket or address', nargs=address_nargs, + default=default_address) return parser.parse_args() From 104ae54462652187002b25e4df4bd11ccce485d6 Mon Sep 17 00:00:00 2001 From: Joakim Nordling Date: Tue, 17 Nov 2020 14:44:55 +0200 Subject: [PATCH 2/2] Update README with details about the environment variable --- README.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.rst b/README.rst index 14e262a..9c5ccee 100644 --- a/README.rst +++ b/README.rst @@ -23,6 +23,13 @@ You'll now need to call uwsgitop as:: uwsgitop http://127.0.0.1:3031 + +You can also use the `UWSGITOP_ADDRESS` environment variable to define a default socket or address and run uwsgitop without any arguments like this:: + + export UWSGITOP_ADDRESS="/tmp/stats.socket" + uwsgitop + + Installation ------------