Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
1aa11cf7
Commit
1aa11cf7
authored
9 years ago
by
Mark Haines
Browse files
Options
Downloads
Patches
Plain Diff
Allow multiple config files, set up a default config before applying the config files
parent
6b69ddd1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
demo/start.sh
+2
-1
2 additions, 1 deletion
demo/start.sh
synapse/config/_base.py
+37
-21
37 additions, 21 deletions
synapse/config/_base.py
synapse/config/homeserver.py
+1
-1
1 addition, 1 deletion
synapse/config/homeserver.py
with
40 additions
and
23 deletions
demo/start.sh
+
2
−
1
View file @
1aa11cf7
...
...
@@ -30,7 +30,8 @@ for port in 8080 8081 8082; do
rm
$DIR
/etc/
$port
.config
python
-m
synapse.app.homeserver
\
--generate-config
"localhost:
$https_port
"
\
--generate-config
\
-H
"localhost:
$https_port
"
\
--config-path
"
$DIR
/etc/
$port
.config"
\
python
-m
synapse.app.homeserver
\
...
...
This diff is collapsed.
Click to expand it.
synapse/config/_base.py
+
37
−
21
View file @
1aa11cf7
...
...
@@ -117,51 +117,59 @@ class Config(object):
config
=
yaml
.
load
(
default_config
)
if
not
os
.
path
.
exists
(
config_dir_path
):
os
.
makedirs
(
config_dir_path
)
self
.
invoke_all
(
"
generate_keys
"
,
config
)
return
default_config
return
default_config
,
config
@classmethod
def
load_config
(
cls
,
description
,
argv
,
generate_section
=
None
):
result
=
cls
()
obj
=
cls
()
config_parser
=
argparse
.
ArgumentParser
(
add_help
=
False
)
config_parser
.
add_argument
(
"
-c
"
,
"
--config-path
"
,
action
=
"
append
"
,
metavar
=
"
CONFIG_FILE
"
,
help
=
"
Specify config file
"
)
config_parser
.
add_argument
(
"
--generate-config
"
,
metavar
=
"
SERVER_NAME
"
,
action
=
"
store_true
"
,
help
=
"
Generate a config file for the server name
"
)
config_parser
.
add_argument
(
"
-H
"
,
"
--server-name
"
,
help
=
"
The server name to generate a config file for
"
)
config_args
,
remaining_args
=
config_parser
.
parse_known_args
(
argv
)
if
not
config_args
.
config_path
:
config_parser
.
error
(
"
Must supply a config file.
\n
A config file can be automatically
"
"
generated using
\"
--generate-config SERVER_NAME
"
"
generated using
\"
--generate-config
-h
SERVER_NAME
"
"
-c CONFIG-FILE
\"
"
)
config_dir_path
=
os
.
path
.
dirname
(
config_args
.
config_path
[
0
])
config_dir_path
=
os
.
path
.
abspath
(
config_dir_path
)
if
config_args
.
generate_config
:
server_name
=
config_args
.
generate_config
config_path
=
config_args
.
config_path
server_name
=
config_args
.
server_name
if
not
server_name
:
print
"
Most specify a server_name to a generate config for.
"
sys
.
exit
(
1
)
(
config_path
,)
=
config_args
.
config_path
if
os
.
path
.
exists
(
config_path
):
print
"
Config file %r already exists. Not overwriting
"
%
(
config_args
.
config_path
)
sys
.
exit
(
0
)
config_dir_path
=
os
.
path
.
dirname
(
config_
args
.
config
_path
)
config_dir_path
=
os
.
path
.
abspath
(
config_dir_path
)
sys
.
exit
(
1
)
if
not
os
.
path
.
exists
(
config_
dir
_path
)
:
os
.
makedirs
(
config_dir_path
)
with
open
(
config_path
,
"
wb
"
)
as
config_file
:
config_file
.
write
(
result
.
generate_config
(
config_dir_path
,
server_name
)
config_bytes
,
config
=
obj
.
generate_config
(
config_dir_path
,
server_name
)
obj
.
invoke_all
(
"
generate_keys
"
,
config
)
config_file
.
write
(
config_bytes
)
print
(
"
A config file has been generated in %s for server name
"
"
'
%s
'
with corresponding SSL keys and self-signed
"
...
...
@@ -174,8 +182,16 @@ class Config(object):
)
sys
.
exit
(
0
)
config
=
cls
.
read_config_file
(
config_args
.
config_path
)
result
.
invoke_all
(
"
read_config
"
,
config
)
specified_config
=
{}
for
config_path
in
config_args
.
config_path
:
yaml_config
=
cls
.
read_config_file
(
config_path
)
specified_config
.
update
(
yaml_config
)
server_name
=
specified_config
[
"
server_name
"
]
_
,
config
=
obj
.
generate_config
(
config_dir_path
,
server_name
)
config
.
update
(
specified_config
)
obj
.
invoke_all
(
"
read_config
"
,
config
)
parser
=
argparse
.
ArgumentParser
(
parents
=
[
config_parser
],
...
...
@@ -183,9 +199,9 @@ class Config(object):
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
,
)
result
.
invoke_all
(
"
add_arguments
"
,
parser
)
obj
.
invoke_all
(
"
add_arguments
"
,
parser
)
args
=
parser
.
parse_args
(
remaining_args
)
result
.
invoke_all
(
"
read_arguments
"
,
args
)
obj
.
invoke_all
(
"
read_arguments
"
,
args
)
return
result
return
obj
This diff is collapsed.
Click to expand it.
synapse/config/homeserver.py
+
1
−
1
View file @
1aa11cf7
...
...
@@ -37,5 +37,5 @@ class HomeServerConfig(TlsConfig, ServerConfig, DatabaseConfig, LoggingConfig,
if
__name__
==
'
__main__
'
:
import
sys
sys
.
stdout
.
write
(
HomeServerConfig
().
generate_config
(
sys
.
argv
[
1
],
sys
.
argv
[
2
])
HomeServerConfig
().
generate_config
(
sys
.
argv
[
1
],
sys
.
argv
[
2
])
[
0
]
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment