A daemon is a background process that enhances the reliability of your eCash node. It ensures continuous operation, automatic restarts in case of failure, and provides a comprehensive log of events. This is particularly beneficial for node operators who require dependable and uninterrupted service.
This guide will walk you through the process of using bitcoind.service to daemonize your eCash node, creating and switching user modes, and managing and monitoring your service.
Create a User
If you have already created a user, you can skip this step.
First, we need to create a new user to run the eCash service. In this guide, we will use John as the username, but you should replace it with your own username.
# apt-get update
# apt-get install sudo
# adduser John
# usermod -aG sudo John
# su - JohnThen follow the prompts to set up the password and other user information.
Using a User-Level Service File
Before we create a new service file, let's move the latest version of bitcoin-abc to a directory without the version number. This directory will be the launch location for the daemon:
$ mkdir -p ~/bitcoin-abc/bin/
$ cp ~/bitcoin-abc-0.28.8/bin/bitcoind ~/bitcoin-abc/bin/
$ cp ~/bitcoin-abc-0.28.8/bin/bitcoin-cli ~/bitcoin-abc/bin/Note: When a new version is released, you need to update these two files.
Now, let's fetch the template service file from the official Bitcoin-ABC repository:
$ wget https://raw.githubusercontent.com/Bitcoin-ABC/bitcoin-abc/master/contrib/init/bitcoind.serviceLet's move this file to the appropriate directory:
$ mkdir -p ~/.config/systemd/user
$ mv bitcoind.service ~/.config/systemd/user/bitcoind.serviceTo set the service to start automatically at system startup, you first need to allow the systemd user instance to continue running after the user logs out:
$ loginctl enable-linger JohnTo reload the service configuration file, run:
$ systemctl --user daemon-reloadThen, enable the service:
This step will allow the bitcoind.service to start upon reboot.
$ systemctl --user enable bitcoindThen, you can start the service with the following command:
(If you run it without shutting down the node, an error might occur. You should shut down the node first.)
./bitcoin-abc-0.28.8/bin/bitcoin-cli stopStart the bitcoind
$ systemctl --user start bitcoindTo check the status of the service, run:
$ systemctl --user status bitcoindThen, to confirm whether the bitcoind service is set to start automatically at system startup, you can use:
$ systemctl --user is-enabled bitcoindThe output enabled indicates that the bitcoind service is set to start automatically at system startup, while disabled indicates it is not.
You can check your bitcoind.service log for any potential issues or updates.
In a few environments, you may encounter errors when using systemctl. This could be due to issues with the DBUS path. You can resolve this by running the following command:
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus

