eCash Node Daemon Setup GuideeCash Node Daemon Setup GuideeCash Node Daemon Setup Guide
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 - John
Then 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.service
Let's move this file to the appropriate directory:
$ mkdir -p ~/.config/systemd/user
$ mv bitcoind.service ~/.config/systemd/user/bitcoind.service
To 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 John
To reload the service configuration file, run:
$ systemctl --user daemon-reload
Then, enable the service:
This step will allow the bitcoind.service to start upon reboot.
$ systemctl --user enable bitcoind
Then, 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 stop
Start the bitcoind
$ systemctl --user start bitcoind
To check the status of the service, run:
$ systemctl --user status bitcoind
Then, to confirm whether the bitcoind service is set to start automatically at system startup, you can use:
$ systemctl --user is-enabled bitcoind
The 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