| title | Run Pactus as a Systemd Service |
|---|---|
| weight | 11 |
Systemd is a system and service manager for Linux that helps manage how programs start up, run, and shut down. It also handles system processes, logging, and basic service monitoring.
Before setting up Pactus to run with systemd, ensure you have the following:
- Download the latest version of Pactus CLI for your Linux system from here.
- This guide assumes that
systemdis installed and running on your Linux distribution. Most modern distributions usesystemdby default.
After initializing your Pactus node with pactus-daemon init, you can set up
a systemd service to run it in the background.
-
Create a Service File: Open a terminal and create a new service file in the
/etc/systemd/system/directory with superuser permissions:sudo nano /etc/systemd/system/pactus.service
-
Add the Following Content to the service file, replacing
<USER_NAME>with your actual Linux username:[Unit] Description=Pactus Daemon Service After=network.target [Service] Type=simple User=<USER_NAME> ExecStart=/home/<USER_NAME>/pactus-cli/pactus-daemon start -w /home/<USER_NAME>/pactus Restart=on-failure RestartSec=10 [Install] WantedBy=multi-user.target
-
Reload Systemd Configuration: After creating or modifying the service file, reload the systemd to recognize the new service:
sudo systemctl daemon-reload
-
Start and Enable the Service: Start the service immediately and enable it to start on boot:
sudo systemctl start pactus sudo systemctl enable pactus -
Check Service Status: Check the status of your service to ensure it is running correctly:
sudo systemctl status pactus
If the service fails to start or behaves unexpectedly, check the logs using journalctl:
sudo journalctl -u pactus.serviceThis command will show you the log entries related to your service, helping you diagnose issues.