Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Spike using svc to start and stop #6

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55143,7 +55143,7 @@ function buildUserDataScript(githubRegistrationToken, label) {
`cd "${config.input.runnerHomeDir}"`,
'export RUNNER_ALLOW_RUNASROOT=1',
'export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1',
'export INSTANCE_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)',
'export INSTANCE_ID=$(cat /var/lib/cloud/data/instance-id)',
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --name "$INSTANCE_ID" --labels ${label}`,
'./run.sh',
];
Expand All @@ -55152,13 +55152,15 @@ function buildUserDataScript(githubRegistrationToken, label) {
'#!/bin/bash',
'mkdir actions-runner && cd actions-runner',
'case $(uname -m) in aarch64) ARCH="arm64" ;; amd64|x86_64) ARCH="x64" ;; esac && export RUNNER_ARCH=${ARCH}',
'curl -O -L https://github.com/actions/runner/releases/download/v2.280.3/actions-runner-linux-${RUNNER_ARCH}-2.280.3.tar.gz',
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.280.3.tar.gz',
'curl -O -L https://github.com/actions/runner/releases/download/v2.283.2/actions-runner-linux-${RUNNER_ARCH}-2.283.2.tar.gz',
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.283.2.tar.gz',
'export RUNNER_ALLOW_RUNASROOT=1',
'export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1',
'export INSTANCE_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)',
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --name "$INSTANCE_ID" --labels ${label}`,
'./run.sh',
'export INSTANCE_ID=$(cat /var/lib/cloud/data/instance-id)',
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --name "$INSTANCE_ID" --labels ${label} --ephemeral`,
"sed -i 's/\\(ExecStart=.*\\)/\\1\\nExecStopPost=shutdown -h now/' bin/actions.runner.service.template",
'sudo ./svc.sh install',
'sudo ./svc.sh start',
];
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ function buildUserDataScript(githubRegistrationToken, label) {
'#!/bin/bash',
'mkdir actions-runner && cd actions-runner',
'case $(uname -m) in aarch64) ARCH="arm64" ;; amd64|x86_64) ARCH="x64" ;; esac && export RUNNER_ARCH=${ARCH}',
'curl -O -L https://github.com/actions/runner/releases/download/v2.280.3/actions-runner-linux-${RUNNER_ARCH}-2.280.3.tar.gz',
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.280.3.tar.gz',
'curl -O -L https://github.com/actions/runner/releases/download/v2.283.2/actions-runner-linux-${RUNNER_ARCH}-2.283.2.tar.gz',
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.283.2.tar.gz',
'export RUNNER_ALLOW_RUNASROOT=1',
'export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1',
'export INSTANCE_ID=$(cat /var/lib/cloud/data/instance-id)',
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --name "$INSTANCE_ID" --labels ${label}`,
'./run.sh',
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --name "$INSTANCE_ID" --labels ${label} --ephemeral`,
"sed -i 's/\\(ExecStart=.*\\)/\\1\\nExecStopPost=shutdown -h now/' bin/actions.runner.service.template",
'sudo ./svc.sh install',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EC2 user data scripts are run as root so you shouldn't need sudo here.

In a related vein, if you don't want to run the runner as root, you can also pass in a different user to run the service as. See example.

'sudo ./svc.sh start',
];
}
}
Expand Down