gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-merchant-demos] branch master updated: Extend config.


From: gnunet
Subject: [taler-taler-merchant-demos] branch master updated: Extend config.
Date: Mon, 15 Nov 2021 21:40:56 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository taler-merchant-demos.

The following commit(s) were added to refs/heads/master by this push:
     new 6844bf0  Extend config.
6844bf0 is described below

commit 6844bf021208e88085b877cc9603196df55c0242
Author: ms <ms@taler.net>
AuthorDate: Mon Nov 15 21:40:14 2021 +0100

    Extend config.
    
    Give possibility to serve HTTP via Unix domain sockets.
---
 talermerchantdemos/cli.py | 62 +++++++++++++++++++++++++++++------------------
 1 file changed, 38 insertions(+), 24 deletions(-)

diff --git a/talermerchantdemos/cli.py b/talermerchantdemos/cli.py
index fd836c6..78f9049 100644
--- a/talermerchantdemos/cli.py
+++ b/talermerchantdemos/cli.py
@@ -57,7 +57,7 @@ def handle_serve_uwsgi(config, which_shop):
         "talermerchantdemos.{}:app".format(which_shop),
         "--need-app",
         "--cache2",
-        "name=paid_articles,items=500",
+        "name=paid_articles,items=500"
     ]
     if serve_uwsgi == "tcp":
         port = config[which_shop]["uwsgi_port"].value_int(required=True)
@@ -85,33 +85,47 @@ def handle_serve_uwsgi(config, which_shop):
 #
 # @param args command line options.
 def handle_serve_http(config, which_shop, port=None):
-    if port is None:
-        port = config[which_shop]["http_port"].value_int(required=True)
-    if port is None:
-        print("'http_port' configuration option is missing")
-        exit(1)
-    spec = ":%d" % (port,)
+    params = [
+        "uwsgi",
+        "uwsgi",
+        *arg_load_python,
+        "--master",
+        "--die-on-term",
+        "--log-format",
+        UWSGI_LOGFMT,
+        "--module",
+        "talermerchantdemos.{}:app".format(which_shop),
+    ]
+    
+    # Takes precedence.
+    if port:
+        http_serve = "tcp"
+    else:
+        http_serve = config[which_shop]["http_serve"].value_string(
+        required=False,
+        default="tcp"
+    ).lower()
+
+    if http_serve == "tcp":
+        port_launch = 
config[which_shop]["http_port"].value_int(required=False) if not port else port
+        if not port_launch:
+            sys.stderr.write("Port number wasn't found in config and in 
arguments.")
+            exit(1)
+        params.extend(["--http", f":{port_launch}"])
+
+    if http_serve == "unix":
+        path = 
config[which_shop]["http_unixpath"].value_filename(required=True)
+        mode = 
config[which_shop]["http_unixpath_mode"].value_filename(required=True)
+        params.extend(["--http-socket", path])
+        params.extend(["--chmod-socket=" + mode])
+        os.makedirs(os.path.dirname(path), exist_ok=True)
+
     try:
-        os.execlp(
-            "uwsgi",
-            "uwsgi",
-            *arg_load_python,
-            "--master",
-            "--die-on-term",
-            "--log-format",
-            UWSGI_LOGFMT,
-            "--http",
-            spec,
-            "--module",
-            "talermerchantdemos.{}:app".format(which_shop),
-        )
+        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)
 
-
 def handle_serve_from_config(config_obj, which_shop):
     try:
         if (

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]