Run Anemos with systemd on Linux

Run Anemos with systemd on Linux

Preface

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.

Prerequisites

Before setting up Anemos to run with systemd, ensure you have the following:

  • Download the latest version of Anemos CLI for your Linux system from here.
  • This guide assumes that systemd is installed and running on your Linux distribution. Most modern distributions use systemd by default.

Creating a systemd Service

To create a systemd service for Anemos, follow these steps:

  1. Initialize the Anemos Node: Before running the service, initialize the Anemos node with this command:
anemos-daemon init
  1. 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/anemos.service
  1. Add the Following Content to the service file, replacing <USER_NAME> with your actual username:
[Unit]
Description=Anemos Daemon Service
After=network.target

[Service]
Type=simple
User=<USER_NAME>
ExecStart=/home/<USER_NAME>/anemos-cli/anemos-daemon start -w /home/<USER_NAME>/anemos
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
  1. Reload Systemd Configuration: After creating or modifying the service file, reload the systemd to recognize the new service:
sudo systemctl daemon-reload
  1. Start and Enable the Service: Start the service immediately and enable it to start on boot:
sudo systemctl start anemos
sudo systemctl enable anemos
  1. Check Service Status: Check the status of your service to ensure it is running correctly:
sudo systemctl status anemos

Managing the Service

Use these commands to manage the Anemos service with systemd:

  • Start the Service:

    sudo systemctl start anemos
  • Stop the Service:

    sudo systemctl stop anemos
  • Restart the Service:

    sudo systemctl restart anemos
  • Enable the Service to Start on Boot:

    sudo systemctl enable anemos
  • Disable the Service from Starting on Boot:

    sudo systemctl disable anemos

Checking Logs

If the service fails to start or behaves unexpectedly, check the logs using journalctl:

sudo journalctl -u anemos.service

This command will show you the log entries related to your service, helping you diagnose issues.

Last updated on