Skip to main content

Run an edge as a service

This guide explains how to setup and run an SA Engine edge device as a service to ensure that it starts automatically when the edge device starts.

The following steps are involved in this guide:

  • Add a non-root user to execute SA Engine
  • Download and install SA Engine
  • Add connection configuration
  • Make sure SA Engine starts at boot using systemctl
Requirements

This guide assume that you are running your SA Engine edge process on a Linux distributiom where systemd is available. systemd is configured using the systemctl command.

For this guide to work you need the following:

  1. Download and unpack eaas-files_4.16.5.tar.gz.

     sa.edge.service
    sa_edge.sh
    sa_edge_connection.conf

    The sa.edge.service file is a systemd service specification file.

  2. Administrative rights (i.e. root access) on your edge device.

Run SA Engine as a non-root user

It is wise to run SA Engine as a non-root user. If you haven't already, add a user that will run SA Engine.

Warning

It is unwise to run a service with higher access than necessary.

This command adds a user engine, which can be used to run SA Engine as a service.

$> sudo useradd -r -m -d /home/engine -s /bin/bash engine

Note that this user should not be allowed to escalate its privileges using sudo.

Download and install SA Engine

  1. Download and unpack sa_engine_core_linux_x64.tar.gz from https://studio.streamanalyze.com/download/#tlinux.

  2. In sa_edge.sh, set the environment variable SA_ENGINE_HOME to the path where the sa.engine folder you unpacked is located.

    export SA_ENGINE_HOME=<path/to/sa.engine/>
  3. In sa_edge.sh, set the environment variable SA_HOME to the path where the SA Engine runtime files should be located.

    export SA_HOME=<path/to/sa/home>

Add connection configuration

  1. Create a connection configuration from an SA Studio instance connected to your federation. See the SA Studio manual.

  2. Replace the content of sa_edge_connection.conf with the raw connection configuration generated in step 1.

  3. In sa_edge.sh, set the environment variable SA_EDGE_DEVICE_NAME to the name this edge device will use when connecting to the federation. This should match the name used when generating the connection configuration in step 1.

    export SA_EDGE_DEVICE_NAME=<your-edge-device-name>
  4. These files should now be readable by the user to run sa.edge.service:

    FileDescription
    sa.edge.serviceThe service specification, edited for your environment.
    sa_edge.shThe start script, edited for your environment.
    sa_edge_connection.confConnection configuration generated in step 1.
  5. Verify that you can connect your edge device to the federation manually by running:

    $> <path-to-sa_edge.sh>/sa_edge.sh

systemctl

  1. Get the file sa.edge.service and edit the fields so that they match your desired configuration.

    PlaceholderDescription
    <path-to-sa_edge.sh>The full path to the file sa_edge.sh, e.g., /home/<user>/sa_edge.
    <path-to-sa-home>The full path to SA_HOME, e.g., /home/<user>/SA.
    <desired-user>The user you want to run sa.edge.service.
  2. Install service sa.edge.service as root:

    > sudo systemctl link /path/to/sa.edge.service
  3. Reload daemon and enable services.

    > sudo systemctl daemon-reload
    > sudo systemctl enable sa.edge.service # make service start on boot
    > sudo systemctl start sa.edge.service # start service right now
  4. Verify that services were started.

    > sudo systemctl status sa.edge.service

    This status command should show the most recent output from sa.edge.service.