Skip to content

Commit

Permalink
Replace SERVICE_NAME with inline string in the runner prog
Browse files Browse the repository at this point in the history
It's referenced rarely, and it makes harder to read.
  • Loading branch information
enescakir committed Apr 30, 2024
1 parent 02cb6f7 commit 1756660
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions prog/vm/github_runner.rb
Expand Up @@ -105,8 +105,6 @@ def update_billing_record
end
end

SERVICE_NAME = "runner-script"

def vm
@vm ||= github_runner.vm
end
Expand Down Expand Up @@ -293,7 +291,7 @@ def setup_info
# We initiate an API call and a SSH connection under the same label to avoid
# having to store the encoded_jit_config.
vm.sshable.cmd("sudo -- xargs -I{} -- systemd-run --uid runner --gid runner " \
"--working-directory '/home/runner' --unit #{SERVICE_NAME} --remain-after-exit -- " \
"--working-directory '/home/runner' --unit runner-script --remain-after-exit -- " \
"/home/runner/actions-runner/run-withenv.sh {}",
stdin: response[:encoded_jit_config])

Expand All @@ -315,7 +313,7 @@ def setup_info
runner_id = runner.fetch(:id)
# If the runner script is not started yet, we can delete the runner and
# register it again.
if vm.sshable.cmd("systemctl show -p SubState --value #{SERVICE_NAME}").chomp == "dead"
if vm.sshable.cmd("systemctl show -p SubState --value runner-script").chomp == "dead"
Clog.emit("Deregistering runner because it already exists") { {github_runner: github_runner.values.merge({runner_id: runner_id})} }
github_client.delete("/repos/#{github_runner.repository_name}/actions/runners/#{runner_id}")
nap 5
Expand All @@ -329,7 +327,7 @@ def setup_info
end

label def wait
case vm.sshable.cmd("systemctl show -p SubState --value #{SERVICE_NAME}").chomp
case vm.sshable.cmd("systemctl show -p SubState --value runner-script").chomp
when "exited"
github_runner.incr_destroy
nap 15
Expand Down

0 comments on commit 1756660

Please sign in to comment.