How to Start HVR as Service Using Systemd in Linux
Question
How can I start HVR as a service using systemd in Linux?
Environment
HVR 5
Answer
This article explains how to run HVR 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
As the
root
user, or a user withsudo
privilege, create a file calledhvr.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
As the
root
user, or a user withsudo
priviledge, create a file calledhvr@.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
- ExecStart should use option
–plogin
for PAM authentication - ExecStart should point to the hvr in
$HVR_HOME
directory - Environment variable for
$HVR_HOME
should be path ofhvr_home
on your machine - Environment variable for
$HVR_CONFIG
should be path ofhvr_config
on your machine - Environment variable for
$HVR_TMP
can be anytmp
location on your machine
- ExecStart should use option
Enable the service using below command:
$ systemctl enable hvr.socket
Start the service using below command:
$ systemctl start hvr.socket
Verify whether service is running using below command:
$ systemctl status hvr.socket
The above setup allows you to start HVR as a service. There is no need to start hvrremotelistener every time. This service is started whenever the system is rebooted.