Management & Monitoring

This section is designed to gather steps for managing the different services around the xcash-dpops program, getting logs and monitoring the activity.

systemd services

systemd is generally used to manage low-level programs in Linux-based systems. It's a reliable way to automatically run programs on startup, and manage and monitor the different services.

In systemd, a unit refers to any resource that the system knows how to operate on and manage. This is the primary object that the systemd tools know how to deal with. These resources are defined using configuration files called unit files. Whether you installed with the autoinstaller script or manually, the programs needed to run the X-Cash consensus are managed in systemd with unit files.

The different services needed for the X-Cash consensus running on the server are listed below:

xcash-dpops.service
xcash-daemon.service
xcash-rpc-wallet.service
mongodb.service
firewall.service
xcash-dpops.service
[Unit]
Description=X-Cash DPOPS Daemon background process
[Service]
Type=simple
LimitNOFILE=infinity
User=root
WorkingDirectory=~/xcash-official/xcash-dpops/build
ExecStart=~/xcash-official/xcash-dpops/build/xcash-dpops --block-verifiers-secret-key BLOCK_VERIFIER_SECRET_KEY
Restart=always
[Install]
WantedBy=multi-user.target
xcash-daemon.service
[Unit]
Description=X-Cash Daemon background process
[Service]
Type=simple
User=root
ExecStart=~/xcash-official/xcash-core/build/release/bin/xcash-wallet-rpc --wallet-file ~/xcash-official/xcash-wallets/WALLET --password PASSWORD --rpc-bind-port 18285 --confirm-external-bind --daemon-port 18281 --disable-rpc-login --trusted-daemon
Restart=always
[Install]
WantedBy=multi-user.target
xcash-rpc-wallet.service
[Unit]
Description=X-Cash RPC Wallet background process
[Service]
Type=simple
User=root
ExecStart=~/xcash-official/xcash-core/build/release/bin/xcash-wallet-rpc --wallet-file ~/xcash-official/xcash-wallets/WALLET --password PASSWORD --rpc-bind-port 18285 --confirm-external-bind --daemon-port 18281 --disable-rpc-login --trusted-daemon
Restart=always
[Install]
WantedBy=multi-user.target
mongodb.service
[Unit]
Description=MongoDB Database Server
After=network.target
[Service]
Type=forking
User=root
Type=oneshot
RemainAfterExit=yes
PIDFile=~/xcash-official/systemdpid/mongod.pid
ExecStart=~/xcash-official/mongodb-linux-x86_64-ubuntu1804-4.4.0-rc7-36-gcf4ac31/bin/mongod --fork --syslog --dbpath /data/db
LimitFSIZE=infinity
LimitCPU=infinity
LimitAS=infinity
LimitNOFILE=64000
LimitNPROC=64000
LimitMEMLOCK=infinity
TasksMax=infinity
TasksAccounting=false
[Install]
WantedBy=multi-user.target
firewall.service
[Unit]
Description=firewall
[Service]
Type=oneshot
RemainAfterExit=yes
User=root
ExecStart=~/xcash-official/xcash-dpops/scripts/firewall/firewall_script.sh
[Install]
WantedBy=multi-user.target

All the unit files are located in /lib/systemd/system/

Services Management

At some point, you might have to need to restart or check the status of the services, either to reflect a change you have made, to update, or to run the program with different parameters.

Start
Restart
Stop
Status
Start

To start a systemd service, run:

systemctl start SERVICE

Example:

systemctl start xcash-dpops
Restart

To restart a systemd service, run:

systemctl restart SERVICE

Example:

systemctl restart xcash-rpc-wallet
Stop

To stop a systemd service, run:

systemctl stop SERVICE

Example:

systemctl stop xcash-daemon
Status

To check the status of a systemd service, run:

systemctl status SERVICE

Example:

systemctl status mongodb

Output:

● mongodb.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongodb.service; disabled; vendor preset: enabled)
Active: active (exited) since Mon 2020-06-08 11:50:51 CEST; 38min ago
Main PID: 14852 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/mongodb.service
└─14854 /root/xcash-official/mongodb-linux-x86_64-ubuntu1804-4.2.3/bin/mongod --fork --syslog --dbpath /data/db/

Monitoring & Logging

While the services are running in the background, you might want to check the outputs of the different programs.

To monitor the services, we are using journalctl which fetch the journal of the systemd services. Using journalctl without paramaters will show the full contents of the journal, starting with the oldest entry collected.

For a live logging with better readability, we will limit the output by using the following parameters:

journalctl --unit=SERVICE --follow -n 100 --output cat

To check the xcash-dpops services, you can copy the following commands:

xcash-dpops
xcash-daemon
xcash-rpc-wallet
mongodb
firewall
xcash-dpops
journalctl --unit=xcash-dpops --follow -n 100 --output cat
xcash-daemon
journalctl --unit=xcash-daemon --follow -n 100 --output cat
xcash-rpc-wallet
journalctl --unit=xcash-rpc-wallet --follow -n 100 --output cat
mongodb
journalctl --unit=mongodb --follow -n 100 --output cat
firewall
journalctl --unit=firewall --follow -n 100 --output cat

The xcash-daemon service export its logs in a different place. To display the latest log, use the following command:

tail -n 100 ~/xcash-official/logs/xcash-daemon-log.txt