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

Add --no-daemonize option to synctl #5412

Merged
merged 5 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5412.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add --no-daemonize option to run synapse in the foreground, per issue #4130. Contributed by Soham Gumaste.
19 changes: 16 additions & 3 deletions synctl
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ def abort(message, colour=RED, stream=sys.stderr):
sys.exit(1)


def start(configfile):
def start(configfile, daemonize=True):
write("Starting ...")
args = SYNAPSE
args.extend(["--daemonize", "-c", configfile])

if daemonize:
args.extend(["--daemonize", "-c", configfile])
else:
args.extend(["-c", configfile])

try:
subprocess.check_call(args)
Expand Down Expand Up @@ -143,12 +147,21 @@ def main():
help="start or stop all the workers in the given directory"
" 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()

if options.worker and options.all_processes:
write('Cannot use "--worker" with "--all-processes"', stream=sys.stderr)
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

Expand Down Expand Up @@ -276,7 +289,7 @@ def main():
# 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)
start(configfile, bool(options.no_daemonize))

for worker in workers:
env = os.environ.copy()
Expand Down