diff options
author | Erik Johnston <erik@matrix.org> | 2015-04-28 14:24:08 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-04-28 14:24:08 +0100 |
commit | 9fbcf191889b655d5c93d01a738e5137aa94a354 (patch) | |
tree | 8a403e4b27825447695fe09b54bb2440df734ed5 /synapse/config | |
parent | Merge pull request #126 from matrix-org/csauth (diff) | |
parent | Remove unused imports (diff) | |
download | synapse-9fbcf191889b655d5c93d01a738e5137aa94a354.tar.xz |
Merge pull request #123 from matrix-org/postgres
Postgres
Diffstat (limited to 'synapse/config')
-rw-r--r-- | synapse/config/database.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/synapse/config/database.py b/synapse/config/database.py index 87efe54645..190d119df4 100644 --- a/synapse/config/database.py +++ b/synapse/config/database.py @@ -15,6 +15,7 @@ from ._base import Config import os +import yaml class DatabaseConfig(Config): @@ -26,18 +27,45 @@ class DatabaseConfig(Config): self.database_path = self.abspath(args.database_path) self.event_cache_size = self.parse_size(args.event_cache_size) + if args.database_config: + with open(args.database_config) as f: + self.database_config = yaml.safe_load(f) + else: + self.database_config = { + "name": "sqlite3", + "args": { + "database": self.database_path, + }, + } + + name = self.database_config.get("name", None) + if name == "psycopg2": + pass + elif name == "sqlite3": + self.database_config.setdefault("args", {}).update({ + "cp_min": 1, + "cp_max": 1, + "check_same_thread": False, + }) + else: + raise RuntimeError("Unsupported database type '%s'" % (name,)) + @classmethod def add_arguments(cls, parser): super(DatabaseConfig, cls).add_arguments(parser) db_group = parser.add_argument_group("database") db_group.add_argument( "-d", "--database-path", default="homeserver.db", - help="The database name." + metavar="SQLITE_DATABASE_PATH", help="The database name." ) db_group.add_argument( "--event-cache-size", default="100K", help="Number of events to cache in memory." ) + db_group.add_argument( + "--database-config", default=None, + help="Location of the database configuration file." + ) @classmethod def generate_config(cls, args, config_dir_path): |