Prevent running multiple instances of the gitlab-runner process
Description
Running multiple instances of the gitlab-runner process on a single host can cause some extremely confusing and hard to debug behaviours. Running multiple instances on a single host is almost never a desirable or intended situation to be in and is usually done by accident after a daemon is already running in the background.
Proposal
Add a lock file that the runner checks for on startup. If the lockfile exists, exit the process with an error explaining the situation. If the lock file doesn't exist start as usual.
The lock file can be on the config.toml
file since there can be a case where the user has two GitLab Runners using two different config.toml
files on the same machine. This lock file can either live right next to the config.toml
file (this can have permission issues) or inside of the /tmp
dir
Links to related issues and merge requests / references
Bug that would've been prevented by this feature: #3688 (closed)
FYI @jlenny @steveazz @tmaczukin @ayufan