From 3b9139a8f30a5a59dc4ed8aa24acc959d01ce6b3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 20 Apr 2021 13:35:19 +0200 Subject: plugin loading workaround --- bin/taler-merchant-demos | 69 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/bin/taler-merchant-demos b/bin/taler-merchant-demos index aa63c20..feb4e4d 100755 --- a/bin/taler-merchant-demos +++ b/bin/taler-merchant-demos @@ -42,13 +42,19 @@ UWSGI_LOGFMT = "%(ltime) %(proto) %(method) %(uri) %(proto) => %(status)" # @param command line options. def handle_serve_uwsgi(config, which_shop): serve_uwsgi = config[which_shop]["uwsgi_serve"].value_string(required=True).lower() - params = ["uwsgi", "uwsgi", - "--master", - "--die-on-term", - "--log-format", UWSGI_LOGFMT, - "--module", "talermerchantdemos.{}:app".format(which_shop), - "--need-app", - "--cache2", "name=paid_articles,items=500"] + params = [ + "uwsgi", + "uwsgi", + "--master", + "--die-on-term", + "--log-format", + UWSGI_LOGFMT, + "--module", + "talermerchantdemos.{}:app".format(which_shop), + "--need-app", + "--cache2", + "name=paid_articles,items=500", + ] if serve_uwsgi == "tcp": port = config[which_shop]["uwsgi_port"].value_int(required=True) spec = ":%d" % (port,) @@ -57,15 +63,18 @@ def handle_serve_uwsgi(config, which_shop): spec = config[which_shop]["uwsgi_unixpath"].value_filename(required=True) mode = config[which_shop]["uwsgi_unixpath_mode"].value_filename(required=True) params.extend(["--socket", spec]) - params.extend(["--chmod-socket="+mode]) + params.extend(["--chmod-socket=" + mode]) os.makedirs(os.path.dirname(spec), exist_ok=True) logging.info("launching uwsgi with argv %s", params[1:]) try: os.execlp(*params) except: - sys.stderr.write("Failed to start uwsgi. Please make sure to install uwsgi for Python3.") + sys.stderr.write( + "Failed to start uwsgi. Please make sure to install uwsgi for Python3." + ) sys.exit(1) + ## # This function interprets the 'serve-http' subcommand. # The effect it to launch the blog HTTP service. @@ -79,28 +88,51 @@ def handle_serve_http(config, which_shop, port=None): exit(1) spec = ":%d" % (port,) try: - os.execlp("uwsgi", "uwsgi", - "--master", - "--die-on-term", - "--log-format", UWSGI_LOGFMT, - "--http", spec, - "--module", "talermerchantdemos.{}:app".format(which_shop)) + os.execlp( + "uwsgi", + "uwsgi", + "--if-not-plugin", + "python", + "--plugins", + "python", + "--endif", + "--master", + "--die-on-term", + "--log-format", + UWSGI_LOGFMT, + "--http", + spec, + "--module", + "talermerchantdemos.{}:app".format(which_shop), + ) except: - sys.stderr.write("Failed to start uwsgi. Please make sure to install uwsgi for Python3.") + sys.stderr.write( + "Failed to start uwsgi. Please make sure to install uwsgi for Python3." + ) sys.exit(1) + def handle_serve_from_config(config_obj, which_shop): try: - if config_obj.value_string(which_shop, "serve", required=True).lower() == "http": + if ( + config_obj.value_string(which_shop, "serve", required=True).lower() + == "http" + ): return handle_serve_http(config_obj, which_shop) handle_serve_uwsgi(config_obj, which_shop) except ConfigurationError as ce: print(ce) exit(1) + @click.command("Global shop launcher") @click.option("--config", help="Configuration file", required=False) -@click.option("--http-port", help="HTTP port to serve (if not given, serving comes from config)", required=False, type=int) +@click.option( + "--http-port", + help="HTTP port to serve (if not given, serving comes from config)", + required=False, + type=int, +) @click.argument("which-shop") def demos(config, http_port, which_shop): """WHICH_SHOP is one of: blog, donations, survey or landing.""" @@ -113,4 +145,5 @@ def demos(config, http_port, which_shop): return handle_serve_http(config_obj, which_shop, http_port) handle_serve_from_config(config_obj, which_shop) + demos() -- cgit v1.2.3