Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 122d08b

Browse files
committed
Let synctl use a config directory. (#5904)
2 parents 978f263 + deca277 commit 122d08b

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

changelog.d/5904.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Let synctl accept a directory of config files.

synapse/config/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
from ._base import ConfigError
16+
from ._base import ConfigError, find_config_files
1717

18-
# export ConfigError if somebody does import *
18+
# export ConfigError and find_config_files if somebody does
19+
# import *
1920
# this is largely a fudge to stop PEP8 moaning about the import
20-
__all__ = ["ConfigError"]
21+
__all__ = ["ConfigError", "find_config_files"]

synctl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ from six import iteritems
3030

3131
import yaml
3232

33+
from synapse.config import find_config_files
34+
3335
SYNAPSE = [sys.executable, "-B", "-m", "synapse.app.homeserver"]
3436

3537
GREEN = "\x1b[1;32m"
@@ -135,7 +137,8 @@ def main():
135137
"configfile",
136138
nargs="?",
137139
default="homeserver.yaml",
138-
help="the homeserver config file, defaults to homeserver.yaml",
140+
help="the homeserver config file. Defaults to homeserver.yaml. May also be"
141+
" a directory with *.yaml files",
139142
)
140143
parser.add_argument(
141144
"-w", "--worker", metavar="WORKERCONFIG", help="start or stop a single worker"
@@ -176,8 +179,12 @@ def main():
176179
)
177180
sys.exit(1)
178181

179-
with open(configfile) as stream:
180-
config = yaml.safe_load(stream)
182+
config_files = find_config_files([configfile])
183+
config = {}
184+
for config_file in config_files:
185+
with open(config_file) as file_stream:
186+
yaml_config = yaml.safe_load(file_stream)
187+
config.update(yaml_config)
181188

182189
pidfile = config["pid_file"]
183190
cache_factor = config.get("synctl_cache_factor")

0 commit comments

Comments
 (0)