LogoLogo
PAO DocsCommunity DocsDeveloper DocsPeerplays.com
  • Infrastructure Documentation
  • The Basics
    • Peerplays Node Types
    • Hardware Requirements
    • Obtaining private keys for cli_wallet
    • Using the CLI Wallet
      • CLI Wallet Fundamentals
      • CLI Commands for All Nodes
      • CLI Commands for Witnesses
      • CLI Commands for SONs
        • Updated CLI commands for SON voting
      • Deriving Keys using CLI Wallet
    • Auto-Starting a Node
    • Backup Servers
    • Obtaining Your First Tokens
    • Updating a Witness Node
    • How to create a Peerplays Account?
  • Advanced Topics
    • Private Testnets
      • Peerplays QA environment
      • Private Testnets - Manual Install
    • Reverse Proxy for Enabling SSL
    • Enabling Elasticsearch on a Node
    • Introduction to Faucet
  • Witnesses
    • What is a Witness node?
    • Installation Guides
      • Build and Install
      • Docker Install
      • GitLab Artifact Install
    • How to become a block producing witness?
    • Other Ways to configure a witness node
      • Peerplays API nodes & Installation Guide
      • Configuring Witness Node as Delayed Node
    • What's Next?
  • Sidechain Operator Nodes (SONs)
    • Installation Guides
      • Manual Install
      • Docker Install
      • SON Configuration - Version 1.5.19
      • SON configuration - Version 1.6.0
      • Bitcoin-SONs Sanity Checks
      • ETH-SONs Configuration & Installation
      • Existing SON node upgrade
  • Bookie Oracle Suite (BOS)
    • Introduction to BOS
    • BOS Installation
      • Installing MongoDB
      • Installing Redis
      • Configuration of bos-auto
      • Spinning Up bos-auto
    • BookieSports
      • Installing Bookiesports
      • Synchronizing BOS with BookieSports
      • BookieSports Module Contents
        • Sub Modules
      • Schema
      • Naming Scheme
    • Manual Intervention Tool (MINT)
      • Installing MINT
      • Introduction
  • DATA PROXIES
    • Introduction to Data Proxies
    • How Data Proxies Work
    • Data Proxy Set Up
  • COUCH POTATO
    • Installation
    • Functional Requirements
      • Flow Diagrams
      • Home Page
      • Create Account
      • Dashboard
        • Header
        • Sports Tabs
        • League Tabs
        • Calendar
        • Notifications
        • Replay
        • Account Menu
      • Game Selector
      • Change Password
    • Help
      • User Guide
        • Introduction
        • Home Page
        • Creating an Account
        • Dashboard
          • Replay
          • Account Menu
            • Change Password
        • Game Selector
    • Database
      • Schema
      • Objects
        • Tables
        • Views
    • API
      • Using the API
      • API Reference
        • Objects
        • Error Codes
      • BOS Schema
    • Proxy Payment Considerations
  • Other Documentation
    • Peerplays Home
    • Community Docs
    • Developer Docs
    • Site Reliability Engineering
Powered by GitBook
On this page
  • 1. File Locations
  • 2. Making a Shell Script
  • 3. Auto-starting Methods
  • 3.1. System Service
  • 3.2. Cron Job
  • 4. List of Useful Systemd Commands
  • 5. Glossary

Was this helpful?

Export as PDF
  1. The Basics

Auto-Starting a Node

Configure your server to start your node on system boot-up

There are a few methods that can be used to start up a node on system boot-up. Automating the node to start when the server starts will help minimize downtime, allow the program to run in the background, and aid in making updates to the node software.

1. File Locations

In this tutorial it's assumed that your node was installed at /usr/local/bin. Please ensure the directories you use match your install. For example, programs in /usr/local/bin can be run without specifying the directory. But for the script to run programs located in other directories you'll need to specify the location explicitly, like /home/ubuntu/src/peerplays/programs/witness_node/witness_node.

For nodes installed with Docker, you'll simply need the location of the Docker shell script file (/home/ubuntu/peerplays-docker/run.sh).

2. Making a Shell Script

Making a shell script with logging is a good place to start. You'll be able to use this script to start up the node.

First make a log file to store the outputs of the witness_node program.

sudo touch /var/log/peerplays.log

Find a good place to store the script file. For this tutorial, let's give it it's own directory. Then create a file named start.sh.

cd /home/ubuntu
mkdir node_scripts
cd node_scripts
nano start.sh

Use the text editor of your choice (nano comes with Ubuntu) to create the start.sh file as follows (please select the method which you used to install the node):

#!/bin/bash

witness_node &> /var/log/peerplays.log

Depending on where the programs were installed, you might have to specify the file location explicitly. For example:

#!/bin/bash

cd /home/ubuntu/src/peerplays
./programs/witness_node/witness_node &> /var/log/peerplays.log
#!/bin/bash

cd /home/ubuntu/peerplays-docker
sudo ./run.sh start

In the case of Docker, we don't have to output the logs to another file because we're already maintaining the logs. You can view them with:

cd /home/ubuntu/peerplays-docker
sudo ./run.sh logs

Save and exit the file. Now you'll set the file permissions.

chmod 744 /home/ubuntu/node_scripts/start.sh

3. Auto-starting Methods

You'll only need to use one method to ensure your node starts at system boot. This tutorial will cover two options you can use:

  • Using a system service with Systemd

  • Using a cron job with crontab

3.1. System Service

Setting up a service using Systemd on Ubuntu is the preferred method of auto-starting your node. It allows for greater visibility of the status of the service. We'll make a service file that uses the shell script.

3.1.1. Step 1: Make a System Service File

Now that you have the shell file good to go you'll create a service file. Navigate to /etc/systemd/system and create a file named peerplays.service as below.

cd /etc/systemd/system
nano peerplays.service

Inside the peerplays.service file you'll enter:

[Unit]
Description=Peerplays Node
After=network.target

[Service]
ExecStart=/home/ubuntu/node_scripts/start.sh
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

Save the file and quit.

3.1.2. Step 2: Enable the Service

sudo systemctl enable peerplays.service

Make sure you don't get any errors.

sudo systemctl status peerplays.service

If your node is running, stop it with ctrl + c, then start it back up with the service.

sudo systemctl start peerplays.service

Lastly, check the log file to ensure the node is running properly.

tail -f /var/log/peerplays.log

Success!

You're all done if you've chosen to auto-start your node with systemd. No need for cron!

3.2. Cron Job

Cron jobs are simple to set up. If all you need is to ensure that your node starts when your system boots, a cron job is good enough.

3.2.1. Step 1: Start up Crontab

crontab -e

If this is the first time you've used crontab on your machine, you'll be prompted to pick a text editor.

Crontab will open a file with some comments which explain how to configure a cron job. All you'll need to do is to specify the following at the end of the file:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
@reboot /home/ubuntu/node_scripts/start.sh

Save and quit the file. Now your script will execute whenever your system boots.

In some cases, the crond service needs to be enabled on boot for the configuration to function.

  • To check if the crond service is enabled, use: sudo systemctl status cron.service

  • To enable this service, use: sudo systemctl enable cron.service

Success!

You're all done if you've chosen to auto-start your node with cron. No need for systemd!

4. List of Useful Systemd Commands

Command

Description

Example

systemctl start <SERVICE>

Start a SERVICE (not reboot persistent)

systemctl start peerplays.service

systemctl stop <SERVICE>

Stop a SERVICE (not reboot persistent)

systemctl stop peerplays.service

systemctl restart <SERVICE>

Restart a SERVICE

systemctl restart peerplays.service

systemctl reload <SERVICE>

Reloads the configuration files without interrupting pending operations

systemctl reload peerplays.service

systemctl status <SERVICE>

Shows the status of a SERVICE

systemctl status peerplays.service

systemctl list-units --type=service

Displays the status of all services

n/a

systemctl list-unit-files --type=service

List the services that can be started or stopped

n/a

ls /etc/systemd/system/*.wants/

Print list of services (alternate)

n/a

systemctl enable <SERVICE>

Start SERVICE at next boot

systemctl enable peerplays.service

systemctl disable <SERVICE>

SERVICE won't be started at next boot

systemctl disable peerplays.service

systemctl is-enabled <SERVICE>

Check if a SERVICE is configured to start in the current environment

systemctl is-enabled peerplays.service

systemctl daemon-reload

Run this command after a change in any configuration file (old or new)

n/a

systemctl list-unit-files --type=service

List the services that can be started or stopped

n/a

Command

Description

journalctl -b

Show all messages from last boot

journalctl -b -p err

Show all messages of priority level ERROR and more from last boot

journalctl -f

Follow messages as they appear

journalctl -u <SERVICE>

Show logs for SERVICE

journalctl --full

Display all messages without truncating any

systemctl --state=failed

Display the services that failed to start

systemctl kill <SERVICE>

Gently kill the SERVICE

systemctl list-jobs

Show jobs

Command

Description

systemctl halt

Halts the system

systemctl poweroff

Powers off the system

systemctl reboot

Restarts the system

systemctl suspend

Suspends the system

systemctl hibernate

Hibernates the system

systemctl hybrid-sleep

Hibernates and suspends the system

5. Glossary

Node: The general term for the software that an independent server operator runs to perform some service for the network to which it belongs. In the case of Peerplays, that means validating network transactions, facilitating sidechain asset transfers, providing a gateway to on-chain data, or supplying / validating external data for dapps.

System service (Systemd): On Linux based systems (Peerplays nodes require Ubuntu), systemd is a system and service manager. In essence, it's an init system used to bootstrap user space and manage user processes. Systemd is the name of the program.

Cron job (crontab): A time-based job scheduler in Unix-like operating systems. Users who set up and maintain software environments use cron to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals. Crontab (cron table) is the file that cron uses to schedule tasks.

PreviousDeriving Keys using CLI WalletNextBackup Servers

Last updated 1 year ago

Was this helpful?