Skip to content

Instantly share code, notes, and snippets.

@necessary129
Last active November 23, 2021 20:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save necessary129/5dfbb140e4727496b0ad2bf801c10fdc to your computer and use it in GitHub Desktop.
Save necessary129/5dfbb140e4727496b0ad2bf801c10fdc to your computer and use it in GitHub Desktop.
Systemd service for synapse workers
[Unit]
Description=Matrix Synapse Worker %i
PartOf=matrix-synapse.service
[Service]
Type=simple
ExecStart=/usr/bin/python -B /path/to/synapse_worker.py -c /etc/matrix-synapse/homeserver.yaml -c /etc/matrix-synapse/conf.d/ -c /etc/matrix-synapse/workers/common.yaml -c /etc/matrix-synapse/workers/%i.yaml
User=matrix-synapse
WorkingDirectory=/var/lib/matrix-synapse
EnvironmentFile=/etc/default/matrix-synapse
[Install]
WantedBy=multi-user.target
from importlib import import_module
import sys
from synapse.config.homeserver import HomeServerConfig
from synapse.util.logcontext import LoggingContext
def main():
config = HomeServerConfig.load_config("Worker", sys.argv[1:])
app = config.worker_app
worker = import_module(app)
with LoggingContext('main'):
worker.start(sys.argv[1:])
if __name__ == '__main__':
main()
@ambadyanands
Copy link

@necessary129 getting the following error after upgrading synapse from v1.44.0 to 1.47.1. any idea why?

Traceback (most recent call last):
  File "synapse_worker", line 17, in <module>
    main()
  File "synapse_worker", line 11, in main
    app = config.worker_app
AttributeError: 'HomeServerConfig' object has no attribute 'worker_app'

@ambadyanands
Copy link

Found the issue. Synapse changed how configuration variables are referenced through a series of changes: matrix-org/synapse#10985.

Fxied it by changing config.worker_app to config.worker.worker_app in line number 9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment