forked from MirrorHub/synapse
Fix synctl and duplicate worker spawning (#8798)
Synctl did not check if a worker thread was already running when using `synctl start` and would naively start a fresh copy. This would sometimes lead to cases where many duplicate copies of a single worker would run. This fix adds a pid check when starting worker threads and synctl will now refuse to start individual workers if they're already running.
This commit is contained in:
parent
59a995f38d
commit
7127855741
2 changed files with 8 additions and 0 deletions
1
changelog.d/8798.bugfix
Normal file
1
changelog.d/8798.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Fix a bug where synctl could spawn duplicate copies of a worker. Contributed by Waylon Cude.
|
7
synctl
7
synctl
|
@ -358,6 +358,13 @@ def main():
|
|||
for worker in workers:
|
||||
env = os.environ.copy()
|
||||
|
||||
# Skip starting a worker if its already running
|
||||
if os.path.exists(worker.pidfile) and pid_running(
|
||||
int(open(worker.pidfile).read())
|
||||
):
|
||||
print(worker.app + " already running")
|
||||
continue
|
||||
|
||||
if worker.cache_factor:
|
||||
os.environ["SYNAPSE_CACHE_FACTOR"] = str(worker.cache_factor)
|
||||
|
||||
|
|
Loading…
Reference in a new issue