azure-devopsservicesystemdazure-devops-self-hosted-agent

Self Hosted Agent service startup getting failed on VM restart


I have installed a self hosted agent in my company's private cloud VM (followed documentation from Microsoft and it got successfully installed as service and running.

Now I tried to test it as system startup, so rebooted my machine. After reboot when I am checking the status of service using sudo ./svc.sh status seeing below error

/etc/systemd/system/vsts.agent.Organization.Ppe\x2dItem\x2dPrice\x2dAgent\x2dPool.pc1231bg1111.service
● vsts.agent.Organization.Ppe\x2dItem\x2dPrice\x2dAgent\x2dPool.pc1231bg1111.service - Azure Pipelines Agent (Organization.Ppe-Item-Price-Agent-Pool.pc1231bg1111)
   Loaded: loaded (/etc/systemd/system/vsts.agent.Organization.Ppe\x2dItem\x2dPrice\x2dAgent\x2dPool.pc1231bg1111.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2024-03-29 06:51:24 GMT; 7min ago
  Process: 1047 ExecStart=/home/OrgDomain+svc-Itemsrvce/myagent/runsvc.sh (code=exited, status=217/USER)
 Main PID: 1047 (code=exited, status=217/USER)

Mar 29 06:51:24 pc1231bg1111.tgrc.myorg.org systemd[1]: Started Azure Pipelines Agent (Organization.Ppe-Item…1053).
Mar 29 06:51:24 pc1231bg1111.tgrc.myorg.org systemd[1]: vsts.agent.Organization.Ppe\x2dItem\x2dPrice\x2dAgen…7/USER
Mar 29 06:51:24 pc1231bg1111.tgrc.myorg.org systemd[1]: vsts.agent.Organization.Ppe\x2dItem\x2dPrice\x2dAgen…code'.

My agent directory

-rwxr-xr-x  1 OrgDomain+svc-Itemsrvce OrgDomain+domain users  2014 Feb 22 08:27 run.sh
-rw-r--r--  1 OrgDomain+svc-Itemsrvce OrgDomain+domain users  2753 Feb 22 08:27 run-docker.sh
-rw-r--r--  1 OrgDomain+svc-Itemsrvce OrgDomain+domain users  9465 Feb 22 08:27 license.html
-rwxr-xr-x  1 OrgDomain+svc-Itemsrvce OrgDomain+domain users   726 Feb 22 08:27 env.sh
-rwxr-xr-x  1 OrgDomain+svc-Itemsrvce OrgDomain+domain users  3173 Feb 22 08:27 config.sh
drwxr-xr-x  7 OrgDomain+svc-Itemsrvce OrgDomain+domain users    82 Feb 22 08:28 externals
-rwxr-xr-x  1 OrgDomain+svc-Itemsrvce OrgDomain+domain users  4643 Mar  8 12:32 svc.sh
drwxr-xr-x  7 OrgDomain+svc-Itemsrvce OrgDomain+domain users    80 Mar 12 12:24 _work
drwxr-xr-x 27 OrgDomain+svc-Itemsrvce OrgDomain+domain users 16384 Mar 29 06:41 bin
-rwxr-xr-x  1 OrgDomain+svc-Itemsrvce OrgDomain+domain users   512 Mar 29 06:41 runsvc.sh
drwxr-xr-x  3 OrgDomain+svc-Itemsrvce OrgDomain+domain users    19 Mar 29 06:49 _diag

Service under /etc/systemd/system/

-rw-rw-r--  1 root root  369 Mar 29 06:41 'vsts.agent.MyOrg.Ppe\x2dItem\x2dPrice\x2dAgent\x2dPool.pc1231bg1111.service'

Could someone suggest how can I debug it further to find root cause ?

Thanks


Solution

  • Main PID: 1047 (code=exited, status=217/USER)

    The error 217 indicate the user did not exist at the time the service tried to start. The cause of the issue could be that the user used to run the agent service is not valid.

    To solve this issue, we need to create a local user account and use the local user account to install and run the service.

    The local user account means that the actual user account on Linux machine(e.g. root).