Improved shutdown / reboot consistency

This commit is contained in:
Taylor Helsper 2020-04-22 21:59:37 -05:00
parent c4290a4849
commit 028ebba09c
18 changed files with 33 additions and 1 deletions

View File

@ -6,6 +6,7 @@ Description=Bitcoin daemon
After=network.target mynode.service
[Service]
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStartPre=/usr/bin/wait_on_uploader.sh
ExecStartPre=/bin/sh -c 'cat /mnt/hdd/mynode/quicksync/.quicksync_complete'
EnvironmentFile=/mnt/hdd/mynode/bitcoin/env

View File

@ -7,6 +7,7 @@ Wants=bitcoind.service
After=bitcoind.service
[Service]
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStartPre=/usr/bin/wait_on_bitcoin.sh
ExecStartPre=/usr/bin/wait_on_electrs.sh
WorkingDirectory=/opt/mynode/btc-rpc-explorer

View File

@ -9,6 +9,7 @@ Requires=docker.service network-online.target bitcoind.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStart=/bin/bash -c '. "/opt/mynode/btcpayserver/btcpay-env.sh" && cd "$BTCPAY_BASE_DIRECTORY" && . helpers.sh && btcpay_up'
ExecStop=/bin/bash -c '. "/opt/mynode/btcpayserver/btcpay-env.sh" && cd "$BTCPAY_BASE_DIRECTORY" && . helpers.sh && btcpay_down'
ExecReload=/bin/bash -c '. "/opt/mynode/btcpayserver/btcpay-env.sh" && cd "$BTCPAY_BASE_DIRECTORY" && . helpers.sh && btcpay_restart'

View File

@ -9,6 +9,7 @@ After=mynode.service
[Service]
Type=simple
KillMode=control-group
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStart=/usr/bin/mynode_docker_images.sh
User=root
Group=root

View File

@ -8,6 +8,7 @@ After=network.target mynode.service docker_images.service
[Service]
Type=forking
RemainAfterExit=yes
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStartPre=/usr/bin/wait_on_bitcoin.sh
ExecStartPre=/usr/bin/wait_on_docker_image_install.sh
WorkingDirectory=/opt/mynode/dojo/docker/my-dojo

View File

@ -10,6 +10,7 @@ After=bitcoind.service
Type=simple
KillMode=process
EnvironmentFile=/mnt/hdd/mynode/settings/.btcrpc_environment
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStartPre=/usr/bin/wait_on_bitcoin.sh
ExecStart=/usr/bin/electrs --timestamp --db-dir /mnt/hdd/mynode/electrs --electrum-rpc-addr 0.0.0.0:50001 --cookie="mynode:${BTC_RPC_PASSWORD}" --jsonrpc-import --bulk-index-threads 3 --index-batch-size 12 --daemon-rpc-addr 127.0.0.1:8332 --txid-limit 100 --tx-cache-size 10000 -vvvv
User=bitcoin

View File

@ -6,6 +6,7 @@ Description=Glances
After=network.target
[Service]
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStart=/usr/bin/glances -w
User=root
Group=root

View File

@ -7,6 +7,7 @@ Wants=bitcoind.service
After=bitcoind.service
[Service]
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStartPre=/usr/bin/pre_lnd.sh
ExecStartPre=/usr/bin/wait_on_bitcoin.sh
ExecStart=/usr/local/bin/lnd --caches.channel-cache-size=35000 --ignore-historical-gossip-filters --accept-keysend

View File

@ -7,6 +7,7 @@ Wants=lnd.service
After=lnd.service
[Service]
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStartPre=/usr/bin/wait_on_lnd.sh
Environment=PORT=3000
WorkingDirectory=/opt/mynode/LndHub

View File

@ -8,6 +8,7 @@ After=www.service docker_images.service
[Service]
EnvironmentFile=/mnt/hdd/mynode/settings/.btcrpc_environment
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStartPre=/usr/bin/wait_on_bitcoin.sh
ExecStartPre=/usr/bin/wait_on_docker_image_install.sh
ExecStart=/usr/bin/docker run --rm --name mempoolspace -p 4080:80 -e BITCOIN_NODE_HOST=172.17.0.1 -e BITCOIN_NODE_USER=mynode -e BITCOIN_NODE_PASS=${BTC_RPC_PASSWORD} -e MEMPOOL_REFRESH_RATE_MS=10000 mempoolspace

View File

@ -8,6 +8,7 @@ After=mynode.service docker_images.service
[Service]
WorkingDirectory=/opt/mynode/netdata
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStartPre=/usr/bin/wait_on_bitcoin.sh
ExecStart=/usr/local/bin/docker-compose -f netdata-compose.yml up
ExecStop=/usr/local/bin/docker-compose -f netdata-compose.yml down

View File

@ -13,6 +13,7 @@ TimeoutSec=60
Restart=always
RestartSec=30
Nice=5
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStart=/usr/bin/mynode_quicksync.sh
User=bitcoin
Group=bitcoin

View File

@ -7,6 +7,7 @@ Wants=bitcoind.service
After=bitcoind.service
[Service]
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStartPre=/usr/bin/wait_on_lnd.sh
WorkingDirectory=/opt/mynode/RTL
ExecStart=/usr/bin/node rtl

View File

@ -7,6 +7,7 @@ Wants=www.service docker_images.service
After=www.service docker_images.service
[Service]
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStart=/usr/bin/docker run --rm --name webssh2 -p 2222:2222 -v /opt/mynode/webssh2/config.json:/usr/src/config.json webssh2
ExecStop=/usr/bin/docker stop -t 2 webssh2

View File

@ -4,6 +4,7 @@ After=tor.service
[Service]
WorkingDirectory=/opt/mynode/whirlpool
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStart=/usr/bin/java -jar /opt/mynode/whirlpool/whirlpool.jar --server=mainnet --tor --auto-mix --mixs-target=3 --listen
User=bitcoin
Group=bitcoin

View File

@ -0,0 +1,12 @@
#!/bin/bash
# Wait to see if bitcoind is synced
echo "Checking if device is shutting down..."
if [ ! -f "/tmp/shutting_down" ]; then
echo "Not shutting down!"
exit 0
fi
echo "Device is shutting down... delay and exit failure"
sleep 30s
exit 1

View File

@ -440,6 +440,8 @@ fi
# Enable any new/required services
systemctl enable bitcoind
systemctl enable lnd
systemctl enable firewall
systemctl enable invalid_block_check
systemctl enable usb_driver_check

View File

@ -1,10 +1,13 @@
#!/bin/bash
# Mark we are shutting down
touch /tmp/shutting_down
# Stop additional services
systemctl stop glances
systemctl stop lndhub
systemctl stop netdata
systemctl stop glances
systemctl stop rtl
systemctl stop webssh2
systemctl stop whirlpool