Running the agent as a service Innovation Release

For continuous metric streaming and to ensure your database remains visible in your Hybrid Manager (HM) estate, configure the agent to run as a service. Running as a service allows it to start automatically on system startup and restart after any errors.

If you don't set up the agent as a service, it streams metrics only when you manually run it. Furthermore, your database will disappear from your HM estate 72 hours after the agent stops streaming.

Finish installing and configuring the agent before setting it up as a service.

Note

Future versions of the agent package may set this up automatically.

This example configures the agent to run on an RHEL 9 machine. However, we provide operating system aids so you know when to replace the values.

Environment variables

You must ensure that any environment variables referenced in the agent configuration file are accessible to the service at runtime.

  1. Create a file using your text editor of choice. This example command uses the vi editor:

    sudo vi /usr/lib/systemd/system/beacon-agent.service

    Other default system directories on AWS EC2 instances are:

    Operating systemDefault system directory
    RHEL/usr/lib/systemd/system/beacon-agent.service
    Rocky Linux/usr/lib/systemd/system/beacon-agent.service
    AlmaLinux/usr/lib/systemd/system/beacon-agent.service
    Ubuntu/etc/systemd/system/beacon-agent.service
    Debian/lib/systemd/system/beacon-agent.service
  2. Paste the following template into the beacon-agent.service file and replace the information in placeholders < >.

    # TEMPLATE 
    
    [Unit]
    Description=Agent
    
    After=network.target
    
    [Service]
    Type=simple
    
    User=<user>
    
    WorkingDirectory=</home/user/>
    
    ExecStart=</usr/local/bin/beacon-agent>
    
    Restart=on-failure
    RestartSec=60
    
    [Install]
    WantedBy=multi-user.target
    Service settingsPlaceholder to replaceGuidelines
    User=<user>Provide the name of the system user that will run the agent.
    WorkingDirectory=</home/user/>Set the working directory to where you stored the .beacon directory. The path depends on the operating system.
    ExecStart=</usr/local/bin/beacon-agent>Provide the path to the directory where the agent was installed. The path depends on the operating system.
  3. Run the following commands to reload, enable, and start your new service. These commands apply to all mentioned operating systems:

    sudo systemctl daemon-reload
    sudo systemctl enable beacon-agent.service
    sudo systemctl start beacon-agent.service
  4. Your agent is now running as a service. Check the logs:

    journalctl -u beacon-agent.service