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
rootuser, or a user withsudoprivilege, create a file calledhvr.socketin the directory/etc/systemd/systemwith 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.targetAs the
rootuser, or a user withsudopriviledge, create a file calledhvr@.servicein the directory/etc/systemd/systemwith 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
–ploginfor PAM authentication - ExecStart should point to the hvr in
$HVR_HOMEdirectory - Environment variable for
$HVR_HOMEshould be path ofhvr_homeon your machine - Environment variable for
$HVR_CONFIGshould be path ofhvr_configon your machine - Environment variable for
$HVR_TMPcan be anytmplocation on your machine
- ExecStart should use option
Enable the service using below command:
$ systemctl enable hvr.socketStart the service using below command:
$ systemctl start hvr.socketVerify 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.