How to create a background process
SystemD is a service of daemons, tools, and libraries designed to run applications, as background processes, centrally on Linux operating systems.
SystemD system services allow you to configure an application to perform automated processes, such as starting when the system boots, or restarting if the application stops for any reason…
In the case of nodes in a blockchain, these services are used to control the node’s application and restart it in the event of a crash.
Create a massad service
To create a service you must perform the following steps:
-Create a massad.service file with the service instructions
-Manage the massad service with the service commands
Create massad.service file
The system file massad.service will contain the instructions of the system service, you have to always save it in the directory:
/ etc / systemd / system /
sudo tee /etc/systemd/system/massad.service > /dev/null << EOF[Unit]Description=Massa NodeAfter=network-online.target[Service]User=rootWorkingDirectory=/home/[USER]/massa/massa-nodeExecStart=/home/[USER]/massa/target/release/massa-node -p [PASSWORD]Restart=on-failureRestartSec=3LimitNOFILE=65535[Install]WantedBy=multi-user.targetEOF
If file has been created successfully, you will be able to see its content:
Command: cat /etc/systemd/system/massad.service
Make sure that the file has root permissions :
Command: chmod 777 massad.service
Manage the massad service
To manage the systemctl service you have several specific commands:
Activate and start daemon from massad :
Command: sudo systemctl daemon-reloadCommand: sudo systemctl enable massad
Command: sudo systemctl start massad
Check if the daemon has started successfully
status parameter allows you to see the status information about the service, this command is essential to see if it is running or not.
Command: sudo systemctl status massad
To exit this screen execute:
CTRL + C
Check daemon logs in real time
The journalctl command allows you to view the log generated by the service
Command: sudo journalctl -u massad –f
To exit this screen execute:
CTRL + C
In case you need to restart the system:
Command: sudo systemctl restart massad