Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: NotATether on March 29, 2022, 03:06:33 PM



Title: Bitcoind immediately getting shutdown signal on systemd
Post by: NotATether on March 29, 2022, 03:06:33 PM
I have just force restarted my unresponsive server with Bitcoind running on it, and because it wasn't running as a service automatically before, I have created a systemd service for it which I have enabled and activated, but for some reason, something is constantly shutting it down (cleanly), and restarting it in an infinite loop!

Bitcoin Core version: 22.0
OS: Ubuntu 20.04 LTS

My bitcoin.conf:

Code:
rpcuser=#erased
rpcpassword=#erased
daemon=1
rpcallowip=0.0.0.0
whitebind=127.0.0.1:8332
whitebind=127.0.0.1:8333

My Bitcoind unit file:

Code:
[Unit]
Description=Bitcoin Core service
After=network.target
StartLimitIntervalSec=0

[Service]
User=root # don't ask (the rest of BTCPayServer is also running as root)
Type=simple
Restart=always
RestartSec=1
ExecStart=/opt/bitcoin-22.0/bin/bitcoind

[Install]
WantedBy=multi-user.target

Debug.log entries:

Code:
2022-03-29T15:05:21Z Bitcoin Core version v22.0.0 (release build)
2022-03-29T15:05:21Z InitParameterInteraction: parameter interaction: -whitebind set -> setting -listen=1
2022-03-29T15:05:21Z Assuming ancestors of block 00000000000000000008a89e854d57e5667df88f1cdef6fde2fbca1de5b639ad have valid signatures.
2022-03-29T15:05:21Z Setting nMinimumChainWork=00000000000000000000000000000000000000001fa4663bbbe19f82de910280
2022-03-29T15:05:21Z Using the 'sse4(1way),sse41(4way)' SHA256 implementation
2022-03-29T15:05:21Z Default data directory /root/.bitcoin
2022-03-29T15:05:21Z Using data directory /root/.bitcoin
2022-03-29T15:05:21Z Config file: /root/.bitcoin/bitcoin.conf
2022-03-29T15:05:21Z Config file arg: daemon="1"
2022-03-29T15:05:21Z Config file arg: rpcallowip="0.0.0.0"
2022-03-29T15:05:21Z Config file arg: rpcpassword=****
2022-03-29T15:05:21Z Config file arg: rpcuser=****
2022-03-29T15:05:21Z Config file arg: whitebind="127.0.0.1:8332"
2022-03-29T15:05:21Z Config file arg: whitebind="127.0.0.1:8333"
2022-03-29T15:05:21Z Using at most 125 automatic connections (1024 file descriptors available)
2022-03-29T15:05:21Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2022-03-29T15:05:21Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2022-03-29T15:05:21Z Script verification uses 7 additional threads
2022-03-29T15:05:21Z scheduler thread start
2022-03-29T15:05:21Z WARNING: option -rpcallowip was specified without -rpcbind; this doesn't usually make sense
2022-03-29T15:05:21Z HTTP: creating work queue of depth 16
2022-03-29T15:05:21Z Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcauth for rpcauth auth generation.
2022-03-29T15:05:21Z HTTP: starting 4 worker threads
2022-03-29T15:05:21Z Using wallet directory /root/.bitcoin/wallets
2022-03-29T15:05:21Z init message: Verifying wallet(s)…
2022-03-29T15:05:21Z init message: Loading banlist…
2022-03-29T15:05:21Z SetNetworkActive: true
2022-03-29T15:05:21Z Using /16 prefix for IP bucketing
2022-03-29T15:05:21Z Cache configuration:
2022-03-29T15:05:21Z * Using 2.0 MiB for block index database
2022-03-29T15:05:21Z * Using 8.0 MiB for chain state database
2022-03-29T15:05:21Z * Using 440.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
2022-03-29T15:05:21Z Shutdown requested. Exiting.
2022-03-29T15:05:21Z Shutdown: In progress...
2022-03-29T15:05:21Z scheduler thread exit
2022-03-29T15:05:21Z Shutdown: done

The about log message occurs in a loop ever 1 second, presumably because systemd is trying to restart it again. There is no obvious error in the logs, but a strange request to shut down as soon as I type systemctl start bitcoind.service.


Title: Re: Bitcoind immediately getting shutdown signal on systemd
Post by: vv181 on March 29, 2022, 03:17:12 PM
Have you tried to increase the restart and limit interval settings?

Or maybe it's likely because you set the Restart=always. Try to change it to other settings like on-failure.

EDIT:

I'm trying to replicate the config, systemd manpage shows

Code:
If set to always, the service will be restarted regardless of whether it exited cleanly or not, got terminated abnormally by a signal, or hit a timeout.

Read more at: https://www.commandlinux.com/man-page/man5/systemd.service.5.html

With the systemd config you used, the bitcoind run successfully but only if I've configured the PIDfile. If it doesn't exists, I could reproduce your issues. I'm not sure where it's wrong, but I believe there is something to do with it.


Title: Re: Bitcoind immediately getting shutdown signal on systemd
Post by: NotATether on March 31, 2022, 02:17:46 PM
Apparently, Bitcoind hates running as root and that's what was causing the shutdown, as with the default systemd unit file settings, it can't even find its home folder. Kind of strange how no error is printed for it though.

I could've ran it as an unprivileged user, which I did as well as c-lightning without problems, but then running BTCPayServer as unprivileged made stupid .NET path not found errors when trying to access the store, making it effectively useless.

Time to go hunting for bargain dedi servers - I blew too much money on VPSs (https://bitcointalk.org/index.php?topic=5392248.msg59705981#msg59705981) to continue with those again.


Title: Re: Bitcoind immediately getting shutdown signal on systemd
Post by: WhyFhy on March 31, 2022, 11:35:53 PM
Apparently, Bitcoind hates running as root and that's what was causing the shutdown, as with the default systemd unit file settings, it can't even find its home folder. Kind of strange how no error is printed for it though.

I could've ran it as an unprivileged user, which I did as well as c-lightning without problems, but then running BTCPayServer as unprivileged made stupid .NET path not found errors when trying to access the store, making it effectively useless.

Time to go hunting for bargain dedi servers - I blew too much money on VPSs (https://bitcointalk.org/index.php?topic=5392248.msg59705981#msg59705981) to continue with those again.

Might I interest you in this?

Perfect node system for just about all use case scenarios.
i5-6440EQ @2.7GHZ Quadcore (505e3)
32gb DDR4L ram
wifi+bluetooth (worlwide)
sim slot
x2 oldschool pci slots
2x sata/power connectors
Nic1+Nic2
x4 com ports  IRQ3,4,5&7 (RS232,RS422,RS485)
GPIO 8 In and out with mapping in bios.
4x 2.0 usb, x4 3.0 usb
1x VGA, 2x DP, 1x HDMI (Intel HD)
No passwords, OROM,SGX
Fanless the whole unit is a heatsink.
Looks like this (https://www.dell.com/en-us/work/shop/cty/embedded-box-pc-5000/spd/embedded-box-pc-5000).
Make offers, open to trades?