Skip to content

Commit

Permalink
Refactor Debian package installer to handle upgrade scenarios better (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Andrew Nikitin authored Feb 8, 2022
1 parent 3d31d0f commit 0156e84
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 31 deletions.
7 changes: 6 additions & 1 deletion build-tools/build-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand Down
22 changes: 22 additions & 0 deletions build-tools/cheqd-noded.service
Original file line number Diff line number Diff line change
@@ -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
28 changes: 0 additions & 28 deletions build-tools/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF > /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
4 changes: 2 additions & 2 deletions build-tools/postremove → build-tools/postpurge
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0156e84

Please sign in to comment.