From 0156e84071e95f46e9357f376d96dd46b1a2cfce Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Tue, 8 Feb 2022 03:17:37 +0300 Subject: [PATCH] Refactor Debian package installer to handle upgrade scenarios better (#279) * Move postremove actions to postpurge * Add systemd service definition file * Compress Debian package generated, add URL to GitHub, and generate changelog file * Added documentation link, and changed restart/timeout parameters Co-authored-by: @ankurdotb --- build-tools/build-deb.sh | 7 ++++++- build-tools/cheqd-noded.service | 22 +++++++++++++++++++++ build-tools/postinst | 28 --------------------------- build-tools/{postremove => postpurge} | 4 ++-- 4 files changed, 30 insertions(+), 31 deletions(-) create mode 100644 build-tools/cheqd-noded.service rename build-tools/{postremove => postpurge} (93%) diff --git a/build-tools/build-deb.sh b/build-tools/build-deb.sh index 86a5493e8..69faf2bc4 100755 --- a/build-tools/build-deb.sh +++ b/build-tools/build-deb.sh @@ -30,9 +30,14 @@ fpm \ --version "${VERSION}" \ --name "cheqd-node" \ --description "cheqd node" \ + --url "https://github.com/cheqd/cheqd-node" --architecture "${ARCH}" \ + --deb-generate-changes \ + --deb-compression gz \ --after-install "postinst" \ - --after-remove "postremove" \ + --deb-after-purge "postpurge" \ + --deb-systemd-enable \ + --deb-systemd cheqd-noded.service \ --depends "logrotate" \ --verbose \ --package "${PKG_PATH}" \ diff --git a/build-tools/cheqd-noded.service b/build-tools/cheqd-noded.service new file mode 100644 index 000000000..69a4a286f --- /dev/null +++ b/build-tools/cheqd-noded.service @@ -0,0 +1,22 @@ +[Unit] +Description=Service for running cheqd-node daemon +After=network.target +Documentation=https://docs.cheqd.io/node + +[Service] +Type=simple +User=cheqd +ExecStart=/usr/bin/cheqd-noded start +Restart=on-failure +RestartSec=30 +StartLimitBurst=5 +StartLimitInterval=60 +TimeoutSec=120 +StandardOutput=syslog +StandardError=syslog +SyslogFacility=syslog +SyslogIdentifier=cheqd-noded +LimitNOFILE=65535 + +[Install] +WantedBy=multi-user.target diff --git a/build-tools/postinst b/build-tools/postinst index 5aefbeed5..ed8860ce1 100644 --- a/build-tools/postinst +++ b/build-tools/postinst @@ -77,31 +77,3 @@ systemctl restart logrotate.service systemctl restart logrotate.timer fi -# Add systemd script -if [ ! -f /lib/systemd/system/cheqd-noded.service ] ; then - cat < /lib/systemd/system/cheqd-noded.service -[Unit] -Description=Service for running cheqd-node daemon -After=network.target - -[Service] -Type=simple -User=cheqd -ExecStart=/usr/bin/cheqd-noded start -Restart=on-failure -RestartSec=10 -StartLimitBurst=10 -StartLimitInterval=200 -TimeoutSec=300 -StandardOutput=syslog -StandardError=syslog -SyslogFacility=syslog -SyslogIdentifier=cheqd-noded -LimitNOFILE=65535 - -[Install] -WantedBy=multi-user.target -EOF - # Reload daemons for systemctl - systemctl daemon-reload -fi diff --git a/build-tools/postremove b/build-tools/postpurge similarity index 93% rename from build-tools/postremove rename to build-tools/postpurge index b0969a4a9..dc1a589a0 100644 --- a/build-tools/postremove +++ b/build-tools/postpurge @@ -17,8 +17,8 @@ if test -f "/etc/rsyslog.d/cheqd-node.conf"; then # Remove syslog conf rm /etc/rsyslog.d/cheqd-node.conf - # Remove symlink to log location - rm /var/log/cheqd-node + # Remove logs + rm -rf /var/log/cheqd-node/ # Restart syslog systemctl restart rsyslog