mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-12 04:14:22 -05:00
Merge pull request #5412 from SohamG/fix-4130
Add --no-daemonize option to synctl
This commit is contained in:
commit
6d1e699b5c
1
changelog.d/5412.feature
Normal file
1
changelog.d/5412.feature
Normal file
@ -0,0 +1 @@
|
|||||||
|
Add --no-daemonize option to run synapse in the foreground, per issue #4130. Contributed by Soham Gumaste.
|
17
synctl
17
synctl
@ -69,10 +69,14 @@ def abort(message, colour=RED, stream=sys.stderr):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def start(configfile):
|
def start(configfile, daemonize=True):
|
||||||
write("Starting ...")
|
write("Starting ...")
|
||||||
args = SYNAPSE
|
args = SYNAPSE
|
||||||
|
|
||||||
|
if daemonize:
|
||||||
args.extend(["--daemonize", "-c", configfile])
|
args.extend(["--daemonize", "-c", configfile])
|
||||||
|
else:
|
||||||
|
args.extend(["-c", configfile])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(args)
|
subprocess.check_call(args)
|
||||||
@ -143,12 +147,21 @@ def main():
|
|||||||
help="start or stop all the workers in the given directory"
|
help="start or stop all the workers in the given directory"
|
||||||
" and the main synapse process",
|
" and the main synapse process",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--no-daemonize",
|
||||||
|
action="store_false",
|
||||||
|
help="Run synapse in the foreground for debugging. "
|
||||||
|
"Will work only if the daemonize option is not set in the config."
|
||||||
|
)
|
||||||
|
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
if options.worker and options.all_processes:
|
if options.worker and options.all_processes:
|
||||||
write('Cannot use "--worker" with "--all-processes"', stream=sys.stderr)
|
write('Cannot use "--worker" with "--all-processes"', stream=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
if options.no_daemonize and options.all_processes:
|
||||||
|
write('Cannot use "--no-daemonize" with "--all-processes"', stream=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
configfile = options.configfile
|
configfile = options.configfile
|
||||||
|
|
||||||
@ -276,7 +289,7 @@ def main():
|
|||||||
# Check if synapse is already running
|
# Check if synapse is already running
|
||||||
if os.path.exists(pidfile) and pid_running(int(open(pidfile).read())):
|
if os.path.exists(pidfile) and pid_running(int(open(pidfile).read())):
|
||||||
abort("synapse.app.homeserver already running")
|
abort("synapse.app.homeserver already running")
|
||||||
start(configfile)
|
start(configfile, bool(options.no_daemonize))
|
||||||
|
|
||||||
for worker in workers:
|
for worker in workers:
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
|
Loading…
Reference in New Issue
Block a user