See original script here: https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service
sudo nano /etc/systemd/system/bitcoind.service
Then enter the text in the file above. We are going to omit some of the arguments:
[Unit]
Description=Bitcoin's distributed currency daemon
After=network.target
[Service]
User=bitcoin
Group=bitcoin
Type=forking
PIDFile=/home/pi/.bitcoin/bitcoind.pid
ExecStart=/usr/bin/bitcoind -daemon -pid=/home/pi/.bitcoin/bitcoind.pid \
Restart=always
PrivateTmp=true
TimeoutStopSec=60s
TimeoutStartSec=2s
StartLimitInterval=120s
StartLimitBurst=5
[Install]
WantedBy=multi-user.target
To prevent your fullnode from crashing you can carry out the following script:
$ sudo apt-get install cron
then:
$ sudo crontab -e
(this will open cron for edition)
and add this line at the end:
0 4 * * * root sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
with thanks to OkToshi who raised this in Issue 4
For testing.
[Unit]
Description=Bitcoin Daemon
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