How To: Start Local Data Processing as a service using systemd in linux?
Scenario:
This article explains how to run Local Data Processing as a service rather than starting the hvrremotelistener on remote machine. For the purpose of this article we will see how the service can be started on tcp port 4343
Steps:
Step 1] As the root user, or a user with sudo priviledge, create a file called hvr.socket in the directory /etc/systemd/system with the following contents:
[Unit] Description=HVR service socket [Socket] ListenStream=4343 Accept=true TriggerLimitIntervalSec=1s TriggerLimitBurst=10000 MaxConnectionsPerSource=100 MaxConnections=500 KeepAlive=true [Install] WantedBy=sockets.target
Step 2] As the root user, or a user with sudo priviledge, create a file called hvr@.service in the directory /etc/systemd/system with the following content:
[Unit] Description=HVR service [Service] Environment="HVR_HOME=/home/hvr/hvr_home" Environment="HVR_CONFIG=/home/hvr/hvr_config" Environment="HVR_TMP=/tmp" User=root ExecStart=/home/hvr/hvr_home/bin/hvr -r -plogin StandardInput=socket KillMode=process [Install] WantedBy=multi-user.target
1) ExecStart should use option –plogin for PAM authentication
2) ExecStart should point to the hvr in $HVR_HOME directory
3) Environment variable for $HVR_HOME should be path of hvr_home on your machine
4) Environment variable for $HVR_CONFIG should be path of hvr_config on your machine
5) Environment variable for $HVR_TMP can be any tmp location on your machine
Step 3] Enable the service using below command
$ systemctl enable hvr.socket
Step 4] Start the service using below command
$ systemctl start hvr.socket
Step 5] Verify whether service is running using below command.
# systemctl status hvr.socket
The above setup allows you to start Local Data Processing as a service and there is no need to start hvrremotelistener every time and this service is started whenever the system is rebooted.