mautrix-docs/bridges/python/setup/systemd.md

793 B

Bridge setup with systemd

{{ #include ../selector.html }}

  1. Create a user for the bridge:
    $ sudo adduser --system mautrix-$bridge --home /opt/mautrix-$bridge
    
  2. Set up the bridge with the normal virtualenv setup. Make sure you use that user and home directory for the bridge.
  3. Create a systemd service file at /etc/systemd/system/mautrix-$bridge.service:
    [Unit]
    Description=mautrix-$bridge bridge
    
    [Service]
    # N.B. If you didn't create a user with the correct home directory, set this
    #      to the directory where config.yaml is (e.g. /opt/mautrix-$bridge).
    WorkingDirectory=~
    ExecStart=/opt/mautrix-$bridge/bin/python -m mautrix_$bridge
    User=mautrix-$bridge
    
    [Install]
    WantedBy=multi-user.target