0

I am trying to set up bitcoind to start at boot as a specific user. I see the process start for a minute and then fail, following boot.

I can start bitcoin as the user just fine with a login and then just run bitcoind. But I cannot pull the same trick off in a boot script.

journlctl -b

Jun 05 16:43:09 mo.trader.com systemd[1]: bitcoind.service: Start operation timed out. Terminating.
Jun 05 16:43:09 mo.trader.com bitcoind[546]: 2020-06-05T15:43:09Z Shutdown requested. Exiting.
Jun 05 16:43:09 mo.trader.com bitcoind[546]: 2020-06-05T15:43:09Z Shutdown: In progress...
Jun 05 16:43:09 mo.trader.com bitcoind[546]: 2020-06-05T15:43:09Z scheduler thread exit
Jun 05 16:43:09 mo.trader.com bitcoind[546]: 2020-06-05T15:43:09Z Shutdown: done
Jun 05 16:43:11 mo.trader.com systemd[1]: bitcoind.service: Control process exited, code=exited, status=1/FAILURE
Jun 05 16:43:11 mo.trader.com systemd[1]: bitcoind.service: Failed with result 'timeout'.
Jun 05 16:43:11 mo.trader.com systemd[1]: Failed to start bitcoin.

.

cat /etc/systemd/system/bitcoind.service 
[Unit]
Description=bitcoin
#After=network.target
After=multi-user.target
Conflicts=rescue.target
AllowIsolate=yes


[Service]
Type=forking
User=bitcoinusr
Group=bitcoinusr

Environment=BITCOIN_PID=/mnt/bitcoin/bitcoin/bitcoind.pid
Environment=BITCOIN_HOME=/home/bitcoinusr/.bitcoin

ExecStart=/usr/local/bin/bitcoind
ExecStop=/bin/kill -15 $MAINPID

[Install]
#WantedBy=multi-user.target
Alias=default.target

.

cat ../bitcoinusr/.bitcoin/bitcoin.conf 
blocksonly=1
dbcache=50
maxorphantx=10
maxmempool=100
datadir=/mnt/bitcoin/bitcoin

How do I get bitcoind to start at boot as user?

UPDATE:

It was a total systemd failure. it actually failed with 'service bitcoind start'. It just took a while to fail out.

1

It looks like you have the bitcoind service listed as a forking service, but have not configured bitcoind as such. forking means that systemd expects the service to daemonize itself, i.e. the command it executes will exit once the service has started. However you have not configured bitcoind to behave in this way. So the bitcoind command that systemd runs will not exit as systemd is expecting it to. It is named forking because the process will call the fork() syscall and then the parent process will exit.

There are two solutions.

  1. Configure bitcoind to daemonize itself. You can do this by adding either daemon=1 to your bitcoin.conf file or adding -daemon to the command in ExecStart.
  2. Change your bitcoind.service file to say that bitcoind isn't expected to daemonize itself. To do this, change Type=forking to Type=simple. This instructs systemd to expect that the process configured with ExecStart will be the main process of the service.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.