From d7f578742b24468bd4839e3706aa90f921d233dc Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sat, 7 Nov 2020 09:08:10 +0100 Subject: [PATCH] bundles/mx-puppet-discord: put bridge repo into subdirectory this avoids recreating config and registration on every update, which in turn avoids restarting synapse --- bundles/mx-puppet-discord/files/service | 4 ++-- bundles/mx-puppet-discord/items.py | 26 ++++++++++++------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/bundles/mx-puppet-discord/files/service b/bundles/mx-puppet-discord/files/service index 5c142c8..4b80cc6 100644 --- a/bundles/mx-puppet-discord/files/service +++ b/bundles/mx-puppet-discord/files/service @@ -5,8 +5,8 @@ After=network.target [Service] User=mx-puppet-discord Group=mx-puppet-discord -ExecStart=/usr/bin/node /opt/mx-puppet-discord/build/index.js -c config.yaml -f registration.yaml -WorkingDirectory=/opt/mx-puppet-discord/ +ExecStart=/usr/bin/node /opt/mx-puppet-discord/src/build/index.js -c /opt/mx-puppet-discord/config.yaml -f /opt/mx-puppet-discord/registration.yaml +WorkingDirectory=/opt/mx-puppet-discord/src/ Restart=on-failure [Install] diff --git a/bundles/mx-puppet-discord/items.py b/bundles/mx-puppet-discord/items.py index 728363a..e7c575f 100644 --- a/bundles/mx-puppet-discord/items.py +++ b/bundles/mx-puppet-discord/items.py @@ -1,6 +1,10 @@ assert node.has_bundle('nodejs') directories = { + '/opt/mx-puppet-discord/src': { + 'owner': 'mx-puppet-discord', + 'group': 'mx-puppet-discord', + }, '/var/log/mx-puppet-discord': { 'owner': 'mx-puppet-discord', }, @@ -10,10 +14,6 @@ files = { '/opt/mx-puppet-discord/config.yaml': { 'owner': 'mx-puppet-discord', 'content_type': 'mako', - 'needs': { - 'git_deploy:/opt/mx-puppet-discord', - 'action:mx-puppet-discord_chown', - }, 'triggers': { 'svc_systemd:mx-puppet-discord:restart', }, @@ -21,10 +21,6 @@ files = { '/opt/mx-puppet-discord/registration.yaml': { 'owner': 'mx-puppet-discord', 'content_type': 'mako', - 'needs': { - 'git_deploy:/opt/mx-puppet-discord', - 'action:mx-puppet-discord_chown', - }, 'triggers': { 'svc_systemd:mx-puppet-discord:restart', }, @@ -33,12 +29,13 @@ files = { 'source': 'service', 'triggers': { 'action:systemd-reload', + 'svc_systemd:mx-puppet-discord:restart', }, } } git_deploy = { - '/opt/mx-puppet-discord': { + '/opt/mx-puppet-discord/src': { 'repo': 'https://github.com/matrix-discord/mx-puppet-discord.git', 'rev': 'master', 'triggers': { @@ -51,22 +48,23 @@ git_deploy = { actions = { 'mx-puppet-discord_chown': { - 'command': 'chown -R mx-puppet-discord:mx-puppet-discord /opt/mx-puppet-discord/*', - 'needed_by': { - 'action:mx-puppet-discord_npm_install', + 'command': 'chown -R mx-puppet-discord:mx-puppet-discord /opt/mx-puppet-discord/src', + 'needs': { + 'user:mx-puppet-discord', }, 'triggered': True, }, 'mx-puppet-discord_npm_install': { - 'command': 'cd /opt/mx-puppet-discord && sudo -u mx-puppet-discord npm install', + 'command': 'cd /opt/mx-puppet-discord/src && sudo -u mx-puppet-discord npm install', 'needs': { + 'action:mx-puppet-discord_chown', 'pkg_apt:nodejs', 'user:mx-puppet-discord', }, 'triggered': True, }, 'mx-puppet-discord_npm_build': { - 'command': 'cd /opt/mx-puppet-discord && sudo -u mx-puppet-discord npm run-script build', + 'command': 'cd /opt/mx-puppet-discord/src && sudo -u mx-puppet-discord npm run-script build', 'needs': { 'action:mx-puppet-discord_npm_install', },