1

I have installed GitHub self-hosted runner on my Ubuntu system. Getting below error when i try to configure it as service.

$ sudo ./svc.sh start
Failed to start actions.runner._services.Linux-Host01.service: Unit actions.runner._services.Linux-Host01.service is not loaded properly: Exec format error.
See system logs and 'systemctl status actions.runner._services.Linux-Host01.service' for details.
Failed: failed to start actions.runner._services.Linux-Host01.service
$ systemctl status actions.runner._services.Linux-Host01.service
● actions.runner._services.Linux-Host01.service - GitHub Actions Runner (_services.Linux-Host01)
   Loaded: error (Reason: Exec format error)
   Active: inactive (dead)
$ cat /etc/systemd/system/actions.runner._services.Linux-Host01.service
[Unit]
Description=GitHub Actions Runner (_services.Linux-Host01)
After=network.target

[Service]
ExecStart=/home/admin.user/actions-runner/runsvc.sh
User=admin.user
WorkingDirectory=/home/admin.user/actions-runner
KillMode=process
KillSignal=SIGTERM
TimeoutStopSec=5min

[Install]
WantedBy=multi-user.target
$ sudo journalctl -u actions.runner._services.Linux-Host01.service -f

Aug 04 08:40:47 Linux-Host01 systemd[1]: /etc/systemd/system/actions.runner._services.Linux-Host01.service:7: Invalid user/group name or numeric ID: admin.user

Additionally have provided executable permission to actions.runner._services.Linux-Host01.service but still it results same error.

What is wrong here?

user4948798
  • 1,924
  • 4
  • 43
  • 89
  • `I have provided executable permission` No, remove them, that's a service file. `Exec format error` You have to run sh or bash or the shell you are using. `ExecStart=/bin/sh /home/admin.user/actions-runner/runsvc.sh` – KamilCuk Aug 03 '22 at 06:46
  • i did that, still same problem occurring. – user4948798 Aug 03 '22 at 07:04
  • From the tag: systemd questions should be for *programming questions* using systemd or its libraries. Questions about *configuring the daemon* (including writing unit files) are better directed to Unix & Linux: https://unix.stackexchange.com. – Rob Aug 03 '22 at 11:03

4 Answers4

1

I have changed User=admin.user to User=uid in the /etc/systemd/system/actions.runner._services.Linux-Host01.service file and then executed

systemctl daemon-reload

Now action service started and it is running fine.

user4948798
  • 1,924
  • 4
  • 43
  • 89
1

This simply means you've not installed the runner

  1. sudo ./svc.sh install // install the runner
  2. sudo ./svc.sh start // then start it

Remember, this is the best way to go about it than using the ./run.sh script, as the runner will always be running in the background.

Use sudo ./svc.sh status to confirm that the runner is up and running.

Muasya
  • 44
  • 4
0

Good morning,

First of all stop the service:

sudo ./svc.sh stop

Then make sure you have given permissions to the user:

sudo usermod -a -G <USER>

Now try to start the service:

sudo ./svc.sh start

And tell me if this works when check the status.

If not works please do the same but sudo permissions:

sudo su

And then try again all without sudo command because you are actually on root.

Have a great day!

euTIMER
  • 681
  • 3
  • 12
  • Good Morning, Firstly thank you so much for assisting me. The above steps unfortunately didn't help. Even i have tried by removing and installing the runner again, however still same issue. – user4948798 Aug 04 '22 at 03:05
  • Good morning, can you try to uninstall again with `sudo ./svc.sh uninstall`. Now please follow the steps using alternative installation `./svc.sh install USERNAME`. You can follow documentation here: https://docs.github.com/en/actions/hosting-your-own-runners/configuring-the-self-hosted-runner-application-as-a-service – euTIMER Aug 04 '22 at 07:34
  • Good Afternoon, Have tried the same yesterday itself. but even this `sudo ./svc.sh uninstall` also fails, It was saying failed to stop and uninstall. – user4948798 Aug 04 '22 at 10:35
0

The issue can be the value of the environment variable $SUDO_USER. Inside svc.sh, it captures it:

run_as_user=${arg_2:-$SUDO_USER}

And then uses sed to inject the user value into the systemd service file:

sed "s/{{User}}/${run_as_user}/g;

This becomes an issue if you performed all the installation of the runner as root and then $SUDO_USER evaluates to a nonroot user. For example, if you are automating the script in the user_data script of an EC2 Instance, make sure to change the ownership of the actions-runner directory to the user that evaluates to $SUDO_USER. In my case, since I use the SSM Agent to connect to ec2 instances, it will be ssm-user (if you use amazon linux 2023, it would be ec2-user and if you use ubuntu, then it would be ubuntu as user).

chown ssm-user -R /actions-runner
./svc.sh install
./svc.sh start
Daniel Viglione
  • 8,014
  • 9
  • 67
  • 101