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
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:
Download and unpack eaas-files_4.16.5.tar.gz.
sa.edge.service
sa_edge.sh
sa_edge_connection.confThe
sa.edge.servicefile is asystemdservice specification file.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.
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
Download and unpack
sa_engine_core_linux_x64.tar.gzfrom https://studio.streamanalyze.com/download/#tlinux.In
sa_edge.sh, set the environment variableSA_ENGINE_HOMEto the path where thesa.enginefolder you unpacked is located.export SA_ENGINE_HOME=<path/to/sa.engine/>In
sa_edge.sh, set the environment variableSA_HOMEto the path where the SA Engine runtime files should be located.export SA_HOME=<path/to/sa/home>
Add connection configuration
Create a connection configuration from an SA Studio instance connected to your federation. See the SA Studio manual.
Replace the content of
sa_edge_connection.confwith the raw connection configuration generated in step 1.In
sa_edge.sh, set the environment variableSA_EDGE_DEVICE_NAMEto 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>These files should now be readable by the user to run
sa.edge.service:File Description 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. Verify that you can connect your edge device to the federation manually by running:
$> <path-to-sa_edge.sh>/sa_edge.sh
systemctl
Get the file
sa.edge.serviceand edit the fields so that they match your desired configuration.Placeholder Description <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.Install service
sa.edge.serviceas root:> sudo systemctl link /path/to/sa.edge.serviceReload 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 nowVerify that services were started.
> sudo systemctl status sa.edge.serviceThis status command should show the most recent output from
sa.edge.service.
