How to run multiple self-hosted runners on a single host #26258
-
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:
or
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) |
Beta Was this translation helpful? Give feedback.
Replies: 16 comments 7 replies
-
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 |
Beta Was this translation helpful? Give feedback.
-
Thank you, I was able to get this working by running |
Beta Was this translation helpful? Give feedback.
-
Hi Dmerrick, I tried to run multiple runners on my self-hosted runners as well. I am getting the below error. Even then I used different working directories for different runners. Could you please let me know what mistake I am doing? Cannot configure the runner because it is already configured. To reconfigure the runner, run ‘config.cmd remove’ or ‘./config.sh remove’ first. |
Beta Was this translation helpful? Give feedback.
-
Hey Pradeep, I’ve got a setup working for starting multiple self-hosted runners on the same host, for different repositories. I have a directory for each repository, and extract the actions runner .tar into each one separately. I generate a token and then run the config.sh inside each directory. So my file structure looks something like: If you’ve got a similar setup, then one thing you may want to check is whether or not you’re using the “–name” positional argument for config.sh. You need to make sure each one has a unique name. Eg: ./config.sh --name <unique_name> --url … Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply Rahul. I wanted two runners for the same repo, is it possible? |
Beta Was this translation helpful? Give feedback.
-
Yep it is possible, I’ve tested it. Just make sure you run config.sh out of separate directories, and make the runner names unique! |
Beta Was this translation helpful? Give feedback.
-
OK, thanks Rahul, I will have a look. |
Beta Was this translation helpful? Give feedback.
-
@ rahul-kumar-saini can you please share some examples of how to deploy multiple runners on a single host for single repository different branches. My scenario is like, I have an ubuntu server where I want to access the develop branch and production branch separately. Thanks |
Beta Was this translation helpful? Give feedback.
-
I have launched a github runner at |
Beta Was this translation helpful? Give feedback.
-
Is this possible single git hub repo with multiple self hosted runner.under that repo one directory point to one runner another directory another runner.how can we do structure in entrypoint.sh if you could help. |
Beta Was this translation helpful? Give feedback.
-
Once we start the github runner for same repo, same host. How do we use that in our Github Actions? |
Beta Was this translation helpful? Give feedback.
-
praveenmak:
See the docs about running on self-hosted runners for more info. We usually add a few more labels when registering the runner so we can select e.g. by instance size. |
Beta Was this translation helpful? Give feedback.
-
how many self-hosted runners we can create in same host ? any limit ? |
Beta Was this translation helpful? Give feedback.
-
Lots of good information here, but I feel like it hasn't really been answered. Is this a way to have multiple runners from a single host? i.e I set up a runner and then link all calls to that runner and it just synchronously runs the calls? Or, is there a way for us to simply have a local repo and when I run a command it fires up each instance required? |
Beta Was this translation helpful? Give feedback.
-
I wanted to share a tip that might help those who want to generate 3+ runners programmatically but who don't want to have to grab new tokens. Although I hear those tokens can be shared, that might not be useful in an install script. When using the Like so:
You can also use this to remove runners with (Please note that $RUNNER_NAME_PREFIX and $REPOSITORY_URL are specific to your needs and $i is just because I'm using this in a loop where $i is incrementing). |
Beta Was this translation helpful? Give feedback.
-
There is a simple wrapper script which setup multi self-hosted GitHub action runners on single host. |
Beta Was this translation helpful? Give feedback.
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