Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
d58cad63
Commit
d58cad63
authored
5 years ago
by
Jorik Schellekens
Committed by
Richard van der Hoff
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Give appropriate exit codes when synctl fails (#5992)
parent
a86a2908
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/5992.feature
+1
-0
1 addition, 0 deletions
changelog.d/5992.feature
synctl
+39
-4
39 additions, 4 deletions
synctl
with
40 additions
and
4 deletions
changelog.d/5992.feature
0 → 100644
+
1
−
0
View file @
d58cad63
Give
appropriate
exit
codes
when
synctl
fails.
This diff is collapsed.
Click to expand it.
synctl
+
39
−
4
View file @
d58cad63
...
...
@@ -71,7 +71,20 @@ def abort(message, colour=RED, stream=sys.stderr):
sys
.
exit
(
1
)
def
start
(
configfile
,
daemonize
=
True
):
def
start
(
configfile
:
str
,
daemonize
:
bool
=
True
)
->
bool
:
"""
Attempts to start synapse.
Args:
configfile: path to a yaml synapse config file
daemonize: whether to daemonize synapse or keep it attached to the current
session
Returns:
True if the process started successfully
False if there was an error starting the process
If deamonize is False it will only return once synapse exits.
"""
write
(
"
Starting ...
"
)
args
=
SYNAPSE
...
...
@@ -83,25 +96,40 @@ def start(configfile, daemonize=True):
try
:
subprocess
.
check_call
(
args
)
write
(
"
started synapse.app.homeserver(%r)
"
%
(
configfile
,),
colour
=
GREEN
)
return
True
except
subprocess
.
CalledProcessError
as
e
:
write
(
"
error starting (exit code: %d); see above for logs
"
%
e
.
returncode
,
colour
=
RED
,
)
return
False
def
start_worker
(
app
:
str
,
configfile
:
str
,
worker_configfile
:
str
)
->
bool
:
"""
Attempts to start a synapse worker.
Args:
app: name of the worker
'
s appservice
configfile: path to a yaml synapse config file
worker_configfile: path to worker specific yaml synapse file
Returns:
True if the process started successfully
False if there was an error starting the process
"""
def
start_worker
(
app
,
configfile
,
worker_configfile
):
args
=
[
sys
.
executable
,
"
-B
"
,
"
-m
"
,
app
,
"
-c
"
,
configfile
,
"
-c
"
,
worker_configfile
]
try
:
subprocess
.
check_call
(
args
)
write
(
"
started %s(%r)
"
%
(
app
,
worker_configfile
),
colour
=
GREEN
)
return
True
except
subprocess
.
CalledProcessError
as
e
:
write
(
"
error starting %s(%r) (exit code: %d); see above for logs
"
%
(
app
,
worker_configfile
,
e
.
returncode
),
colour
=
RED
,
)
return
False
def
stop
(
pidfile
,
app
):
...
...
@@ -292,11 +320,14 @@ def main():
write
(
"
All processes exited; now restarting...
"
)
if
action
==
"
start
"
or
action
==
"
restart
"
:
error
=
False
if
start_stop_synapse
:
# Check if synapse is already running
if
os
.
path
.
exists
(
pidfile
)
and
pid_running
(
int
(
open
(
pidfile
).
read
())):
abort
(
"
synapse.app.homeserver already running
"
)
start
(
configfile
,
bool
(
options
.
daemonize
))
if
not
start
(
configfile
,
bool
(
options
.
daemonize
)):
error
=
True
for
worker
in
workers
:
env
=
os
.
environ
.
copy
()
...
...
@@ -307,12 +338,16 @@ def main():
for
cache_name
,
factor
in
iteritems
(
worker
.
cache_factors
):
os
.
environ
[
"
SYNAPSE_CACHE_FACTOR_
"
+
cache_name
.
upper
()]
=
str
(
factor
)
start_worker
(
worker
.
app
,
configfile
,
worker
.
configfile
)
if
not
start_worker
(
worker
.
app
,
configfile
,
worker
.
configfile
):
error
=
True
# Reset env back to the original
os
.
environ
.
clear
()
os
.
environ
.
update
(
env
)
if
error
:
exit
(
1
)
if
__name__
==
"
__main__
"
:
main
()
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