How to run multiple self-hosted runners on a single host

We’re using self-hosted runners in our organization and it’s working fine. What I want to do now is use bigger instances and run multiple runners per host.

I have a script that uses a PAT to generate a runner token, and then uses that token to start a runner. When I run the script multiple times on the same host, only one will register correctly. I get errors like:

A session for this runner already exists.
2020-09-03 19:26:14Z: Runner connect error: The actions runner 94e9c2e0ca90995c7764c845 already has an active session for owner ip-20-10-43-71.. Retrying until reconnected.

or

Cannot configure the runner because it is already configured. To reconfigure the runner, run 'config.cmd remove' or './config.sh remove' first.

I have noticed that the token I get from the token registration endpoint is the same for each runner I try to launch. While this might be the issue, I see no way to “force” the generation of a new registration token.

I should also mention using a different (randomly-generated) --name and --workdir when I run config.sh.

Hi @dmerrick,

Glad to see you in Github Community Forum!

The error should be due to you didn’t change the directory for the configuration script(config.sh/config.cmd), please change to another workdir for new configuration.

To install multiple self-hosted runner on your host, you should use different workdir and different runner name. The registration token can be identical( or you can rerun the api command to get a new one).

These runners are using same machine env and disk, it’s recommened to create them on different VMs on your host to seperate them.

Thanks

Thank you, I was able to get this working by running config.sh from different directories for each worker.