Azure DevOpsDevelopmentDevOps

Register Linux Azure build agent as service/daemon.

 

Introduction.

In my post https://www.jenx.si/2019/05/27/how-to-setup-private-linux-azure-devops-agent/ I investigated how to put up custom Linux build agent for Azure DevOps.

The problem is that registration to Azure DevOps is done only per session with ./run.sh. If you logout from current session or Ctrl+Break current Job Listener – registration to Azure DevOps is also dropped. So, in production environment this scenario is of no use.

Running ./run.sh

If I start agent registration by running ./run.sh then agent registration lifespan is per user session!

Start & kill.

If I check Azure DevOps portal at point “STARTED” my build agent is online, as shown below:

Build agent online.

But, if I cancel script execution (Ctrl+C -> STOPED point) or if I exit ssh session (exit terminal) my agent goes offline!

Build agent offline.

In general, for build agents we want to be online all the time! So, let’s investigate svn.sh script.

Let’s check svc.sh script.

Linux Azure build agent has svc.sh bash script in installation bundle. Let’s investigate what this script does.

svc.sh help

It’s straightforward, script can install, start, stop, display status and uninstall linux build service.

Install and start Linux service.

That’s it, Linux Azure build agent is running as service. Now, I can disconnect from console (kill session), restart build server and it will automatically register to Azure DevOps on the next boot. Nice!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.