[Unit]
Description=Synapse Matrix homeserver

[Service]
Type=simple
User={{ synapse_user }}
Group={{ synapse_user }}
Environment=LD_PRELOAD={{ synapse_jemalloc }}
{% if system_proxy is defined and system_proxy != '' %}
{% for env in ['http_proxy', 'https_proxy', 'HTTP_PROXY', 'HTTPS_PROXY'] %}
Environment={{ env }}={{ system_proxy | urlsplit('hostname') }}:{{ system_proxy | urlsplit('port') }}
{% endfor %}
{% endif %}
PermissionsStartOnly=yes
ExecStart={{ synapse_root_dir }}/venv/bin/python3 -m synapse.app.homeserver -c {{ synapse_root_dir }}/etc/homeserver.yaml -n
ExecReload=/bin/kill -HUP $MAINPID
PrivateTmp=yes
PrivateDevices=yes
ProtectSystem=full
ProtectHome=yes
NoNewPrivileges=yes
MemoryLimit={{ synapse_max_mem }}M
SyslogIdentifier=matrix-synapse
Restart=on-failure
StartLimitInterval=0
RestartSec=30

[Install]
WantedBy=multi-user.target
