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
Package Registry
Container Registry
Model registry
Operate
Terraform modules
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
Timo Ley
synapse
Commits
b1fddb7f
Commit
b1fddb7f
authored
5 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Factor out a run_generate_config function
parent
a52e1a3b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docker/start.py
+28
-17
28 additions, 17 deletions
docker/start.py
with
28 additions
and
17 deletions
docker/start.py
+
28
−
17
View file @
b1fddb7f
...
...
@@ -33,12 +33,6 @@ def convert(src, dst, environ):
outfile
.
write
(
rendered
)
def
check_arguments
(
environ
,
args
):
for
argument
in
args
:
if
argument
not
in
environ
:
error
(
"
Environment variable %s is mandatory, exiting.
"
%
argument
)
def
generate_config_from_template
(
environ
,
ownership
):
"""
Generate a homeserver.yaml from environment variables
...
...
@@ -108,17 +102,22 @@ def generate_config_from_template(environ, ownership):
return
config_path
# Prepare the configuration
mode
=
sys
.
argv
[
1
]
if
len
(
sys
.
argv
)
>
1
else
None
ownership
=
"
{}:{}
"
.
format
(
environ
.
get
(
"
UID
"
,
991
),
environ
.
get
(
"
GID
"
,
991
))
args
=
[
"
python
"
,
"
-m
"
,
"
synapse.app.homeserver
"
]
def
run_generate_config
(
environ
):
"""
Run synapse with a --generate-config param to generate a template config file
# In generate mode, generate a configuration, missing keys, then exit
if
mode
==
"
generate
"
:
check_arguments
(
environ
,
(
"
SYNAPSE_SERVER_NAME
"
,
"
SYNAPSE_REPORT_STATS
"
,
"
SYNAPSE_CONFIG_PATH
"
)
)
args
+=
[
Args:
environ (dict): environment dictionary
Never returns.
"""
for
v
in
(
"
SYNAPSE_SERVER_NAME
"
,
"
SYNAPSE_REPORT_STATS
"
,
"
SYNAPSE_CONFIG_PATH
"
):
if
v
not
in
environ
:
error
(
"
Environment variable
'
%s
'
is mandatory in `generate` mode.
"
%
(
v
,))
args
=
[
"
python
"
,
"
-m
"
,
"
synapse.app.homeserver
"
,
"
--server-name
"
,
environ
[
"
SYNAPSE_SERVER_NAME
"
],
"
--report-stats
"
,
...
...
@@ -129,6 +128,15 @@ if mode == "generate":
]
os
.
execv
(
"
/usr/local/bin/python
"
,
args
)
# Prepare the configuration
mode
=
sys
.
argv
[
1
]
if
len
(
sys
.
argv
)
>
1
else
None
ownership
=
"
{}:{}
"
.
format
(
environ
.
get
(
"
UID
"
,
991
),
environ
.
get
(
"
GID
"
,
991
))
# In generate mode, generate a configuration, missing keys, then exit
if
mode
==
"
generate
"
:
run_generate_config
(
environ
)
# In normal mode, generate missing keys if any, then run synapse
else
:
if
"
SYNAPSE_CONFIG_PATH
"
in
environ
:
...
...
@@ -136,7 +144,10 @@ else:
else
:
config_path
=
generate_config_from_template
(
environ
,
ownership
)
args
+=
[
args
=
[
"
python
"
,
"
-m
"
,
"
synapse.app.homeserver
"
,
"
--config-path
"
,
config_path
,
# tell synapse to put any generated keys in /data rather than /compiled
...
...
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