The installation script enables you to install and manage your xcash-dpops program easily.
Restart Program
If you have an issue with your program running, or need to do some changes in the settings and need to restart the different program, it is recommended to restart the service using the installer script.
To change your settings from a solo to a shared delegate (and vice versa), you can run the installer script and choose option 9, or change the settings (fees and minimum payout) with option 10.
You will be asked to input a delegate fee and a minimum payout amount to your voters. The script will automatically change the program settings to match your changes.
As a shared delegated, you will have the responsability to distribute the payout to your voters. The voters information and shares are stored locally into your delegate node database. Before attempting to update your node, or do maintenance on your server, it is highly recommended to backup this information.
To backup your shared delegate database, chose option 19:
allows you to change your public_address or VRF key must be using a domain name with delegate add txt record, value @ data is xcash-dpops:MYNEWPUBLICKEY or xcash-dpops:MYNEWVRFKEY you can do 1 or both at the same time does not matter then open ANY wallet (does not need to be the delegate wallet in case you lost it) and type delegate_recover mydomain, and it will do everything for you.
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:
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.
To start a systemd service, run:
systemctl start SERVICE
Example:
systemctl start xcash-dpops
To restart a systemd service, run:
systemctl restart SERVICE
Example:
systemctl restart xcash-rpc-wallet
To stop a systemd service, run:
systemctl stop SERVICE
Example:
systemctl stop xcash-daemon
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:
We can change the motd generated when we login to our server to make it show us basic node information like the service status, our balance and blockchain syncronization status
Optionally, we can to disable all the automatic scripts executed when we log in and only enable ours.
chmod-x/etc/update-motd.d/*
We need to place our script in the update-motd.d directory, we will name it 00-xcash-node-checks and put our script inside
#!/bin/bash# Adjust this variable to the name of your xcash-daemon unit file nameXCASH_DAEMON_SRV=xcash-daemon# Adjust this variable to the name of your xcash-wallets unit file nameXCASH_WALLET_SRV=xcash-rpc-wallet# Adjust this variable to the name of your xcash-dpops unit file nameXCASH_DPOPS_SRV=xcash-dpops# Adjust this variable to the name of your mongodb unit file nameMONGODB_SRV=mongodbDAEMON_URL="http://127.0.0.1:18281/json_rpc"WALLET_URL="http://127.0.0.1:18285/json_rpc"CURL='curl -w "\n" -s -H "Content-Type: application/json" -X'red="\033[01;31m"green="\033[01;32m"reset="\033[0m"functioncheck_height(){iflsof-Pi:18281-sTCP:LISTEN-t>/dev/null ; then DATA=`$CURL GET $DAEMON_URL -d '{"jsonrpc":"2.0","id":"0","method":"get_block_count"}'` HEIGHT=$(echo"$DATA"|grep'"count"'|awk{'print $2'}|seds'|,||g'|tr-d$'\r') STATUS=$(echo"$DATA"|grep'"status"'|awk{'print $2'}|seds'|"||g'|tr-d$'\r')if [ $STATUS =="OK" ]; then STATUS=${green}OK${reset}else SATTUS=${red}FAIL${reset}fiechoecho-e"Blockhain sync status: $STATUS"echo"Blockchain height: $HEIGHT"elseechoecho"X-Cash Daemon service is not running...."echo"Check the $XCASH_DAEMON_SRV service status"fi}functionget_node_balance(){iflsof-Pi:18285-sTCP:LISTEN-t>/dev/null ; then DATA=`$CURL GET $WALLET_URL -d '{"jsonrpc":"2.0","id":"0","method":"get_balance","params":{"account_index":0,"address_indices":[0]}}'` ADDR=$(echo"$DATA"|grep'"address"'|awk{'print $2'}|seds'|"||g'|seds'|,||g'|head-1|tr-d$'\r') UNSPENT_OUTPUTS=$(echo"$DATA"|grep'"num_unspent_outputs"'|awk{'print $2'}|seds'|"||g'|seds'|,||g'|head-1|tr-d$'\r') ATOMIC_TOTAL_BALANCE=$(echo"$DATA"|grep'"balance"'|awk{'print $2'}|seds'|,||g'|head-1|tr-d$'\r') ATOMIC_UNLOCKED_BALANCE=$(echo"$DATA"|grep'"unlocked_balance"'|awk{'print $2'}|seds'|,||g'|head-1|seds"|^M||g"|tr-d$'\r') TOTAL_BALANCE=$((ATOMIC_TOTAL_BALANCE/1000000)) UNLOCKED_BALANCE=$((ATOMIC_UNLOCKED_BALANCE/1000000))echoecho"Public address: $ADDR"echo"Unspent outputs: $UNSPENT_OUTPUTS"echo"Total balance: $TOTAL_BALANCE XCASH"echo"Unlocked balance: $UNLOCKED_BALANCE XCASH"elseechoecho"X-Cash RCP Wallet service is not running...."echo"Check the $XCASH_WALLET_SRV service status"fi}functioncheck_services_status(){echo MONGODB_UP_SINCE=$(systemctlshow $MONGODB_SRV --property=ActiveEnterTimestamp|seds"|ActiveEnterTimestamp=||g") XCASH_DAEMON_UP_SINCE=$(systemctlshow $XCASH_DAEMON_SRV --property=ActiveEnterTimestamp|seds"|ActiveEnterTimestamp=||g") XCASH_WALLET_UP_SINCE=$(systemctlshow $XCASH_WALLET_SRV --property=ActiveEnterTimestamp|seds"|ActiveEnterTimestamp=||g") XCASH_DPOPS_UP_SINCE=$(systemctlshow $XCASH_DPOPS_SRV --property=ActiveEnterTimestamp|seds"|ActiveEnterTimestamp=||g")systemctlis-active $MONGODB_SRV --quiet \&&echo-e ${green}MongoDBserviceisrunningsince...............$MONGODB_UP_SINCE${reset} \||echo-e ${red}MongoDBserviceisnotrunning${reset}systemctlis-active $XCASH_DAEMON_SRV --quiet \&&echo-e ${green}X-CashDaemonserviceisrunningsince.........$XCASH_DAEMON_UP_SINCE${reset} \||echo-e ${red}X-CashDaemonserviceisnotrunning${reset}systemctlis-active $XCASH_WALLET_SRV --quiet \&&echo-e ${green}X-CashRPCWalletserviceisrunningsince.....$XCASH_WALLET_UP_SINCE${reset} \||echo-e ${red}X-CashRPCWalletserviceisnotrunning${reset}systemctlis-active $XCASH_DPOPS_SRV --quiet \&&echo-e ${green}X-CashDPoPSserviceisrunningsince..........$XCASH_DPOPS_UP_SINCE${reset} \||echo-e ${red}X-CashDPoPSserviceisnotrunning${reset}}check_heightget_node_balancecheck_services_statusecho
If you have custom service names you need to adjust the service variable names at the beginning of the script
Then, we need to make it executable
chmod+x/etc/update-motd.d/00-xcash-node-checks
After that, every time we log in to our server by ssh we will see something like this.