From 455702032198dcf9b74b90dc0c303f81be15dd17 Mon Sep 17 00:00:00 2001 From: Jean-Marie Mineau Date: Fri, 6 Aug 2021 04:55:58 +0200 Subject: [PATCH] add bridge daemon --- roles/matrix-bridge-discord/handlers/main.yml | 5 +++++ roles/matrix-bridge-discord/tasks/main.yml | 14 ++++++++++++++ .../templates/bridge_discord.service | 15 +++++++++++++++ roles/matrix-bridge-discord/templates/config.yaml | 4 +--- 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 roles/matrix-bridge-discord/templates/bridge_discord.service diff --git a/roles/matrix-bridge-discord/handlers/main.yml b/roles/matrix-bridge-discord/handlers/main.yml index 61af6f6..8af9f7c 100644 --- a/roles/matrix-bridge-discord/handlers/main.yml +++ b/roles/matrix-bridge-discord/handlers/main.yml @@ -3,3 +3,8 @@ shell: cmd: npm run build chdir: /srv/matrix-appservice-discord + +- name: Restart the discord bridge + systemd: + name: bridge_discord + state: restarted diff --git a/roles/matrix-bridge-discord/tasks/main.yml b/roles/matrix-bridge-discord/tasks/main.yml index ee26763..3289a3c 100644 --- a/roles/matrix-bridge-discord/tasks/main.yml +++ b/roles/matrix-bridge-discord/tasks/main.yml @@ -51,6 +51,7 @@ cmd: npm run build chdir: /srv/matrix-appservice-discord creates: /srv/matrix-appservice-discord/build + notify: Restart the discord bridge - name: Configure the bridge template: @@ -59,6 +60,7 @@ owner: root group: root mode: '0660' + notify: Restart the discord bridge - name: Generate discord-registration.yaml shell: @@ -72,3 +74,15 @@ src: /srv/matrix-appservice-discord/discord-registration.yaml dest: /etc/matrix-synapse/discord-registration.yaml state: link + +- name: Copy the daemon configuration + template: + src: bridge_discord.service + dest: /etc/systemd/system/bridge_discord.service + notify: Restart the discord bridge + +- name: Enable the daemon + systemd: + name: bridge_discord + state: started + enabled: yes diff --git a/roles/matrix-bridge-discord/templates/bridge_discord.service b/roles/matrix-bridge-discord/templates/bridge_discord.service new file mode 100644 index 0000000..867eef4 --- /dev/null +++ b/roles/matrix-bridge-discord/templates/bridge_discord.service @@ -0,0 +1,15 @@ +{{ ansible_managed | comment }} + +[Unit] +Description = Discord Bridge + +[Service] +Environment=NODE_PORT=3000 +Type=simple +User=root +Restart=on-failure +WorkingDirectory=/srv/matrix-appservice-discord +ExecStart=npm start + +[Install] +WantedBy=multi-user.target diff --git a/roles/matrix-bridge-discord/templates/config.yaml b/roles/matrix-bridge-discord/templates/config.yaml index 1c46047..90ecbac 100644 --- a/roles/matrix-bridge-discord/templates/config.yaml +++ b/roles/matrix-bridge-discord/templates/config.yaml @@ -1,6 +1,4 @@ -# This is a sample of the config file showing all available options. -# Where possible we have documented what they do, and all values are the -# default values. +{{ ansible_managed | comment }} bridge: # Domain part of the bridge, e.g. matrix.org