diff --git a/synapse/config/_base.py b/synapse/config/_base.py
index dfc115d8e8..87cdbf1d30 100644
--- a/synapse/config/_base.py
+++ b/synapse/config/_base.py
@@ -28,6 +28,16 @@ class Config(object):
pass
@staticmethod
+ def parse_size(string):
+ sizes = {"K": 1024, "M": 1024 * 1024}
+ size = 1
+ suffix = string[-1]
+ if suffix in sizes:
+ string = string[:-1]
+ size = sizes[suffix]
+ return int(string) * size
+
+ @staticmethod
def abspath(file_path):
return os.path.abspath(file_path) if file_path else file_path
@@ -50,8 +60,9 @@ class Config(object):
)
return cls.abspath(file_path)
- @staticmethod
- def ensure_directory(dir_path):
+ @classmethod
+ def ensure_directory(cls, dir_path):
+ dir_path = cls.abspath(dir_path)
if not os.path.exists(dir_path):
os.makedirs(dir_path)
if not os.path.isdir(dir_path):
diff --git a/synapse/config/database.py b/synapse/config/database.py
index 0d33583a7d..87efe54645 100644
--- a/synapse/config/database.py
+++ b/synapse/config/database.py
@@ -20,7 +20,11 @@ import os
class DatabaseConfig(Config):
def __init__(self, args):
super(DatabaseConfig, self).__init__(args)
- self.database_path = self.abspath(args.database_path)
+ if args.database_path == ":memory:":
+ self.database_path = ":memory:"
+ else:
+ self.database_path = self.abspath(args.database_path)
+ self.event_cache_size = self.parse_size(args.event_cache_size)
@classmethod
def add_arguments(cls, parser):
@@ -30,6 +34,10 @@ class DatabaseConfig(Config):
"-d", "--database-path", default="homeserver.db",
help="The database name."
)
+ db_group.add_argument(
+ "--event-cache-size", default="100K",
+ help="Number of events to cache in memory."
+ )
@classmethod
def generate_config(cls, args, config_dir_path):
diff --git a/synapse/config/logger.py b/synapse/config/logger.py
index 15383b3184..63c8e36930 100644
--- a/synapse/config/logger.py
+++ b/synapse/config/logger.py
@@ -18,6 +18,7 @@ from synapse.util.logcontext import LoggingContextFilter
from twisted.python.log import PythonLoggingObserver
import logging
import logging.config
+import yaml
class LoggingConfig(Config):
@@ -66,7 +67,10 @@ class LoggingConfig(Config):
formatter = logging.Formatter(log_format)
if self.log_file:
- handler = logging.FileHandler(self.log_file)
+ # TODO: Customisable file size / backup count
+ handler = logging.handlers.RotatingFileHandler(
+ self.log_file, maxBytes=(1000 * 1000 * 100), backupCount=3
+ )
else:
handler = logging.StreamHandler()
handler.setFormatter(formatter)
@@ -76,7 +80,8 @@ class LoggingConfig(Config):
logger.addHandler(handler)
logger.info("Test")
else:
- logging.config.fileConfig(self.log_config)
+ with open(self.log_config, 'r') as f:
+ logging.config.dictConfig(yaml.load(f))
observer = PythonLoggingObserver()
observer.start()
diff --git a/synapse/config/server.py b/synapse/config/server.py
index 4f73c85466..31e44cc857 100644
--- a/synapse/config/server.py
+++ b/synapse/config/server.py
@@ -47,8 +47,12 @@ class ServerConfig(Config):
def add_arguments(cls, parser):
super(ServerConfig, cls).add_arguments(parser)
server_group = parser.add_argument_group("server")
- server_group.add_argument("-H", "--server-name", default="localhost",
- help="The name of the server")
+ server_group.add_argument(
+ "-H", "--server-name", default="localhost",
+ help="The domain name of the server, with optional explicit port. "
+ "This is used by remote servers to connect to this server, "
+ "e.g. matrix.org, localhost:8080, etc."
+ )
server_group.add_argument("--signing-key-path",
help="The signing key to sign messages with")
server_group.add_argument("-p", "--bind-port", metavar="PORT",
|