Author

Topic: Systemd, bitcoind and bitcoin node (Read 2800 times)

legendary
Activity: 1143
Merit: 1000
February 16, 2015, 05:37:49 PM
#9
Code:
[Unit]
Description=Bitcoin Daemon
Conflicts=bitcoin-reindex.service
After=network.target

[Service]
User=bitcoin
Group=bitcoin
ExecStart=/usr/bin/bitcoind -daemon=0                       \
                            -conf=/etc/bitcoin/bitcoin.conf \
                            -datadir=/srv/bitcoin           \
                            -pid=/run/bitcoind.pid
ExecReload=/usr/bin/kill -HUP $MAINPID
ExecStop=/usr/bin/bitcoind stop

[Install]
WantedBy=multi-user.target

this is the new systemd file that comes with the new 0.10 release. I suppose that to change my configuration file should be as easy as change -conf=/home/user/.bitcoin/bitcoin.conf
but for datadir how should i list it?
hero member
Activity: 576
Merit: 514
February 10, 2015, 06:16:02 PM
#8
Sorry I've not updated, yesterday had a rough evening, will try to do it tonight. Killing using the pid its not recommended because you might kill someone that you do not want to, it will depend on Type=xx on the systemd file or if you do not use systemd it will relie on how you started it at startup. For the pid i think its safe to use "pidof bitcoind" to get the pid. Thanks again Bitsky and Newar
Using -0 will not kill anything. It just does a check on the process behind the pid. Based on the retval you can then determine what to do.
legendary
Activity: 1143
Merit: 1000
February 10, 2015, 02:23:33 PM
#7
Instead of dealing with excess messages, you could write two wrappers. One which starts bitcoind and puts the pid into a file (unless bitcoind already places a pidfile in /var/run/), and a second one which sends a kill -0 to the pid every 5 min and restart if it's gone. That also has the benefit that you don't delete maybe important mails.

Sorry I've not updated, yesterday had a rough evening, will try to do it tonight. Killing using the pid its not recommended because you might kill someone that you do not want to, it will depend on Type=xx on the systemd file or if you do not use systemd it will relie on how you started it at startup. For the pid i think its safe to use "pidof bitcoind" to get the pid. Thanks again Bitsky and Newar
hero member
Activity: 576
Merit: 514
February 10, 2015, 02:13:55 PM
#6
Instead of dealing with excess messages, you could write two wrappers. One which starts bitcoind and puts the pid into a file (unless bitcoind already places a pidfile in /var/run/), and a second one which sends a kill -0 to the pid every 5 min and restart if it's gone. That also has the benefit that you don't delete maybe important mails.
legendary
Activity: 1358
Merit: 1001
https://gliph.me/hUF
February 10, 2015, 10:35:36 AM
#5
[...]
Btw can you give me the command for the crontab? i've never used it.

As the user who you usually use to run bitcoind, do:
Code:
crontab -e

Add the following lines:
Code:
@reboot /path/to/your/bitcoind
*/30 * * * * /path/to/your/bitcoind
@weekly rm -rf /var/mail/root

The first line starts bitcoind at boot time, the second one starts it every 30 minutes again. In my system this causes a message to be sent to root informing that bitcoind is already running (if it is), so I added the third line to it to save a bit of space. Note that I solely run this system as a node, if you use yours for other stuff your /var/mail/root might be useful for other things and you wouldn't want it deleted once a week. Like I said, it's not the prettiest of hacks, but works fine in this case.
legendary
Activity: 1143
Merit: 1000
February 10, 2015, 09:36:15 AM
#4

Didn't realise systemd is already available in Raspian?

My quick and dirty hack: A crontab that starts the process every x Minutes. If bitcoind already runs it will do nothing, but a log entry. Another crontab takes care removing that log file every so often.

Not using raspbian, using arch linux arm; I added the Restart=on-failure and will try to add the RestartSec=60; I've fixed it i think, ill update this post with the configuration later Smiley, thanks Bitsky

Btw can you give me the command for the crontab? i've never used it.
hero member
Activity: 576
Merit: 514
February 08, 2015, 05:06:48 AM
#3
Try the following in your "[Service]" section:
Code:
RestartSec=60
Restart=on-failure
legendary
Activity: 1358
Merit: 1001
https://gliph.me/hUF
February 08, 2015, 01:17:28 AM
#2

Didn't realise systemd is already available in Raspian?

My quick and dirty hack: A crontab that starts the process every x Minutes. If bitcoind already runs it will do nothing, but a log entry. Another crontab takes care removing that log file every so often.
legendary
Activity: 1143
Merit: 1000
February 07, 2015, 03:37:38 PM
#1
I'm running a bitcoin node on my raspberry pi b+, the thing is that the daemon sometimes just die and i need to restart it
is there any way to check for it using systemd?

the process bitcoind starts at boot with this systemd configuration as bitcoind.service

Code:
[Unit]
Description=Bitcoin daemon service
Wants=network-online.target
After=network-online.target

[Service]
Type=forking
User=HEREGOESYOURUSER
ExecStart=/usr/bin/bitcoind

[Install]
WantedBy=multi-user.target


can anyone post their systemd files so i can take a look?

edit: configuration that worked

Code:
[Unit]
Description=Bitcoin daemon service
Wants=network.target

[Service]
Type=forking
User=HEREGOESYOURUSER
ExecStart=/usr/bin/bitcoind --daemon
Restart=on-failure

[Install]
WantedBy=multi-user.target
Jump to: