[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-backoffice] branch master updated: bin
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-backoffice] branch master updated: bin |
Date: |
Thu, 29 Aug 2019 21:42:09 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository backoffice.
The following commit(s) were added to refs/heads/master by this push:
new f35e031 bin
f35e031 is described below
commit f35e031af84f9199403bed96372fc1c16fc0fa0b
Author: Florian Dold <address@hidden>
AuthorDate: Thu Aug 29 21:42:07 2019 +0200
bin
---
.gitignore | 2 -
bin/taler-merchant-backoffice | 86 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index 93a8e08..14ff5c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,6 @@
talerbackoffice.egg-info/
__pycache__
talerbackoffice/backoffice/static/*.js
-backoffice.wsgi
-taler-merchant-backoffice
js/node_modules/
js/yarn.lock
*.mo
diff --git a/bin/taler-merchant-backoffice b/bin/taler-merchant-backoffice
new file mode 100755
index 0000000..0b190d5
--- /dev/null
+++ b/bin/taler-merchant-backoffice
@@ -0,0 +1,86 @@
+#!/usr/bin/env python3
+
+"""
+Stand-alone script to manage the GNU Taler backoffice.
+"""
+
+import logging
+import argparse
+import sys
+import os
+import site
+from talerbackoffice.talerconfig import TalerConfig
+
+LOGGER = logging.getLogger(__name__)
+
+# No perfect match to our logging format, but good enough ...
+UWSGI_LOGFMT = "%(ltime) %(proto) %(method) %(uri) %(proto) => %(status)"
+
+def handle_serve_http(args):
+ TC = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
+ port = args.port
+ if port is None:
+ port = TC["backoffice-%s" %
args.frontend]["http_port"].value_int(required=True)
+ spec = ":%d" % (port)
+ os.execlp("uwsgi", "uwsgi",
+ "--master",
+ "--die-on-term",
+ "--log-format", UWSGI_LOGFMT,
+ "--http", spec,
+ "--module", "talerbackoffice",
+ "--env", "BACKOFFICE_BACKEND=%s" % TC["backoffice-%s" %
args.frontend]["backend"].value_string(required=True),
+ "--env", "BACKOFFICE_INSTANCES=%s" % TC["backoffice-%s" %
args.frontend]["instances"].value_string(required=True))
+
+def handle_serve_uwsgi(args):
+ TC = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
+ serve_uwsgi = TC["backoffice-%s" %
args.frontend]["uwsgi_serve"].value_string(required=True).lower()
+ params = ["uwsgi", "uwsgi",
+ "--master",
+ "--die-on-term",
+ "--log-format", UWSGI_LOGFMT,
+ "--module", "talerbackoffice",
+ "--env", "BACKOFFICE_BACKEND=%s" % TC["backoffice-%s" %
args.frontend]["backend"].value_string(required=True),
+ "--env", "BACKOFFICE_INSTANCES=%s" % TC["backoffice-%s" %
args.frontend]["instances"].value_string(required=True)]
+ if serve_uwsgi == "tcp":
+ port = TC["backoffice-%s" %
args.frontend]["uwsgi_port"].value_int(required=True)
+ spec = ":%d" % (port,)
+ params.extend(["--socket", spec])
+ elif serve_uwsgi == "unix":
+ spec = TC["backoffice-%s" %
args.frontend]["uwsgi_unixpath"].value_filename(required=True)
+ mode = TC["backoffice-%s" %
args.frontend]["uwsgi_unixpath_mode"].value_filename(required=True)
+ params.extend(["--socket", spec])
+ params.extend(["--chmod-socket="+mode])
+ os.makedirs(os.path.dirname(spec), exist_ok=True)
+ logging.info("launching uwsgi with argv %s", params[1:])
+ os.execlp(*params)
+
+
+PARSER = argparse.ArgumentParser()
+PARSER.set_defaults(func=None)
+PARSER.add_argument('--config', '-c',
+ help="configuration file to use",
+ metavar="CONFIG", type=str,
+ dest="config", default=None)
+PARSER.add_argument('--frontend', '-f',
+ help="fetch config values from [backoffice-<FRONTEND>]
section",
+ metavar="FRONTEND", type=str,
+ dest="frontend", required=True)
+SUB = PARSER.add_subparsers()
+
+P = SUB.add_parser('serve-http', help="Serve over HTTP")
+P.add_argument("--port", "-p", dest="port",
+ type=int, default=None, metavar="PORT")
+P.set_defaults(func=handle_serve_http)
+
+P = SUB.add_parser('serve-uwsgi', help="Serve over UWSGI")
+P.set_defaults(func=handle_serve_uwsgi)
+
+ARGS = PARSER.parse_args()
+if getattr(ARGS, 'func', None) is None:
+ PARSER.print_help()
+ sys.exit(1)
+
+if ARGS.config is not None:
+ os.environ["TALER_CONFIG_FILE"] = ARGS.config
+
+ARGS.func(ARGS)
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-backoffice] branch master updated: bin,
gnunet <=