diff --git a/contrib/apache-eddn.conf b/contrib/apache-eddn.conf index 393c8ed..77bb3c6 100644 --- a/contrib/apache-eddn.conf +++ b/contrib/apache-eddn.conf @@ -1,4 +1,4 @@ -# vim: :filetype=apache +# vim: :filetype=apache tabstop=4 shiftwidth=4 expandtab ########################################################################### # @@ -161,11 +161,26 @@ ProxyPreserveHost On ProxyRequests Off + #################################### + # Gateway, both /upload/ and /stats/ etc + #################################### - # Plain http if setting **empty** CERT_FILE and KEY_FILE in - # the EDDN config.json, else https. - ProxyPass "http://127.0.0.1:8081/" + # Plain http if setting **empty** CERT_FILE and KEY_FILE in + # the EDDN config.json, else https. + ProxyPass "http://127.0.0.1:8081/" + #################################### + + #################################### + # Monitor, /getSoftwares/ etc + #################################### + + # Plain http if setting **empty** CERT_FILE and KEY_FILE in + # the EDDN config.json, else https. + ProxyPass "http://127.0.0.1:9091/" + + #################################### + diff --git a/docs/Running-this-software.md b/docs/Running-this-software.md index 895e0d5..8e925ed 100644 --- a/docs/Running-this-software.md +++ b/docs/Running-this-software.md @@ -531,10 +531,15 @@ config.json. See `contrib/apache-eddn.conf` for how to use TLS instead: ProxyPreserveHost On ProxyRequests Off - # Pass through anything with path prefix /eddn + # Pass through anything with path prefix /eddn to the Gateway ProxPass "http://127.0.0.1:8081/" + + # Anything with /monitor/ is for the Monitor + + ProxPass "http://127.0.0.1:9091/" + This assumes you don't have a dedicated virtual host in this case, hence the diff --git a/src/eddn/Gateway.py b/src/eddn/Gateway.py index 21672d2..6b091d5 100644 --- a/src/eddn/Gateway.py +++ b/src/eddn/Gateway.py @@ -451,7 +451,7 @@ def main() -> None: argsd["keyfile"] = Settings.KEY_FILE app.run( - **argsd + **argsd, ) diff --git a/src/eddn/Monitor.py b/src/eddn/Monitor.py index db731e3..12d3bf7 100644 --- a/src/eddn/Monitor.py +++ b/src/eddn/Monitor.py @@ -4,6 +4,7 @@ import argparse import collections import datetime +import logging import zlib from threading import Thread from typing import OrderedDict @@ -23,6 +24,16 @@ monkey.patch_all() app = Bottle() +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) +__logger_channel = logging.StreamHandler() +__logger_formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(module)s:%(lineno)d: %(message)s") +__logger_formatter.default_time_format = "%Y-%m-%d %H:%M:%S" +__logger_formatter.default_msec_format = "%s.%03d" +__logger_channel.setFormatter(__logger_formatter) +logger.addHandler(__logger_channel) +logger.info("Made logger") + # This import must be done post-monkey-patching! if Settings.RELAY_DUPLICATE_MAX_MINUTES: from eddn.core.DuplicateMessages import DuplicateMessages @@ -30,6 +41,8 @@ if Settings.RELAY_DUPLICATE_MAX_MINUTES: duplicate_messages = DuplicateMessages() duplicate_messages.start() +from eddn.core.EDDNWSGIHandler import EDDNWSGIHandler + def parse_cl_args(): """Parse command-line arguments.""" @@ -286,12 +299,23 @@ def main() -> None: m = Monitor() m.start() app.add_hook("after_request", apply_cors) + + # Build arg dict for args + argsd = { + 'host': Settings.MONITOR_HTTP_BIND_ADDRESS, + 'port': Settings.MONITOR_HTTP_PORT, + 'server': "gevent", + 'log': gevent.pywsgi.LoggingLogAdapter(logger), + 'handler_class': EDDNWSGIHandler, + } + + # Empty CERT_FILE or KEY_FILE means don't put them in + if Settings.CERT_FILE != "" and Settings.KEY_FILE != "": + argsd["certfile"] = Settings.CERT_FILE + argsd["keyfile"] = Settings.KEY_FILE + app.run( - host=Settings.MONITOR_HTTP_BIND_ADDRESS, - port=Settings.MONITOR_HTTP_PORT, - server="gevent", - certfile=Settings.CERT_FILE, - keyfile=Settings.KEY_FILE, + **argsd, )