mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-01-05 12:51:04 -05:00
Send emails OnFailure through dedicated service
The unit-status-email@.service allows being triggered through multiple services with @. Note that everything after the @ is passed to the unit-status-email@.service as parameter. We pass the complete service name OnFailure using %n. The parameter can then be accessed by %i within the unit-status-email@.service. Hence, to pass the service name to our email script for processing we use %i within unit-status-email@.service.
This commit is contained in:
commit
fbd0eb7548
@ -1,13 +1,13 @@
|
||||
[Unit]
|
||||
Description=Pull and build ASB from source
|
||||
Wants=pull-and-build-asb.timer
|
||||
OnFailure=unit-status-email@%n.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
WorkingDirectory=/var/external/asb/xmr-btc-swap
|
||||
ExecStartPre=git pull
|
||||
ExecStart=/home/asb/.cargo/bin/cargo build --release --bin asb
|
||||
ExecStopPost=/bin/sh -c 'if [ "$$EXIT_STATUS" -ne 0 ]; then /usr/local/bin/systemd-email.sh daniel@coblox.tech %n; fi'
|
||||
StandardOutput=append:/var/external/asb/run/logs/pull-and-build.log
|
||||
StandardError=append:/var/external/asb/run/logs/pull-and-build.log
|
||||
User=asb
|
||||
|
@ -1,11 +1,11 @@
|
||||
[Unit]
|
||||
Description=Restart ASB service
|
||||
After=watch-asb-binary-change.path
|
||||
OnFailure=unit-status-email@%n.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/systemctl restart start-asb.service
|
||||
ExecStopPost=/bin/sh -c 'if [ "$$EXIT_STATUS" -ne 0 ]; then /usr/local/bin/systemd-email.sh daniel@coblox.tech %n; fi'
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
@ -1,11 +1,11 @@
|
||||
[Unit]
|
||||
Description=Run the automated swap backend
|
||||
After=start-monero-wallet-rpc.service
|
||||
OnFailure=unit-status-email@%n.service
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/var/external/asb/xmr-btc-swap
|
||||
ExecStart=/home/asb/.cargo/bin/cargo run --release --bin asb -- --config /var/external/asb/run/asb-config/config.toml start
|
||||
ExecStopPost=/bin/sh -c 'if [ "$$EXIT_STATUS" -ne 0 ]; then /usr/local/bin/systemd-email.sh daniel@coblox.tech %n; fi'
|
||||
StandardOutput=append:/var/external/asb/run/logs/start-asb.log
|
||||
StandardError=append:/var/external/asb/run/logs/start-asb.log
|
||||
Restart=on-failure
|
||||
|
@ -1,11 +1,11 @@
|
||||
[Unit]
|
||||
Description=monero-wallet-rpc for the automated swap backend (asb)
|
||||
After=network.target
|
||||
OnFailure=unit-status-email@%n.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/var/external/asb/monero/bin/monero-wallet-rpc --stagenet --daemon-host stagenet.community.xmr.to --rpc-bind-port 38083 --disable-rpc-login --wallet-dir /var/external/asb/monero/data/stagenet/asb-wallets
|
||||
ExecStartPost=/bin/bash -c "i=1; while [ $i -ne 0 ]; do tail -n1 /var/external/asb/monero/bin/monero-wallet-rpc.log | grep 'Starting wallet RPC server'; i=$?; sleep 5; done"
|
||||
ExecStopPost=/bin/sh -c 'if [ "$$EXIT_STATUS" -ne 0 ]; then /usr/local/bin/systemd-email.sh daniel@coblox.tech %n; fi'
|
||||
ExecStartPost=/usr/bin/bash -c "i=1; while [ $i -ne 0 ]; do tail -n1 /var/external/asb/monero/bin/monero-wallet-rpc.log | grep 'Starting wallet RPC server'; i=$?; sleep 5; done"
|
||||
Restart=always
|
||||
User=asb
|
||||
Group=asb
|
||||
|
6
docs/setup/asb/systemd/unit-status-email@.service
Normal file
6
docs/setup/asb/systemd/unit-status-email@.service
Normal file
@ -0,0 +1,6 @@
|
||||
[Unit]
|
||||
Description=%i email notification
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/bash -c '/usr/local/bin/systemd-email.sh daniel@coblox.tech %i'
|
Loading…
Reference in New Issue
Block a user