Create systemd to Harness Delegate on VM

About the configuration,
I will describe a step by step below how to configure the harness-delegate with systems on linux environment , in this example, I will use the following variables:

user=harness
Installation folder = /opt/harness-delegate

The first step is to give permission on the folder to the user and group you want to run as harness-delegate:

#chown -R harness:harness /opt/harness-delegate

The second step is to give execution permission to 2 scripts inside the delegate folder:

#chmod u+x /opt/harness-delegate/stop.sh
#chmod u+x /opt/harness-delegate/start.sh

Now the third step is to create the systemd file with “.service” extension in the /etc/systemd/system folder with the content:
obs: Please, change the user and the directory to your installation config
obs2: the name of file I configured is: harness-delegate.service

[Unit]
Description=harness-delegate
After=network.target
[Service]
WorkingDirectory=/opt/harness-delegate
ExecStart=/opt/harness-delegate/start.sh
ExecStop=/opt/harness-delegate/stop.sh
User=harness
Type=forking
TimeoutSec=60
Restart=on-failure
RestartSec=30
StartLimitInterval=350
StartLimitBurst=10
[Install]
WantedBy=multi-user.target

The last step is to reload the systemd daemon and start and activate the service with the following commands:

#systemctl daemon-reload
#systemctl enable harness-delegate
#systemctl start harness-delegate
2 Likes

Although the service definition is fine, you will probably want to add
LimitNOFILE=10000 to avoid Warning ulimits are too low, because systemd services do not follow ulimit settings set in /etc/security/limits.conf

more on this: How to set ulimits on service with systemd? - Unix & Linux Stack Exchange