Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure the interrupt logic #24

Merged
merged 1 commit into from
Mar 27, 2024
Merged
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
19 changes: 9 additions & 10 deletions gh_actions
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ status_cmd="${name}_status"
load_rc_config $name

gh_actions_running=/var/run/github-runners
gh_actions_sleep="${gh_actions_sleep:-1}"

gh_actions_start()
{
Expand All @@ -39,18 +40,16 @@ gh_actions_stop()
pot info -qr -p ${RUNNER_NAME}-ephemeral > /dev/null 2>&1
if [ $? -eq 0 ] ; then
if [ -f /var/run/github-runners.${RUNNER_NAME} ]; then
# Kill the runner if it isn't in the middle of a job. The
# script will then gracefully terminate.
echo 'pkill -INT github-act-runner' | pot term -p ${RUNNER_NAME}-ephemeral >/dev/null 2>/dev/null
# If force is specified, wait a second for the runner to exit
# and destroy it immediately if it doesn't.
# If force is specified, stop the process immediately.
if [ -n "${rc_force}" ]; then
sleep 1
# FIXME: This is racy.
if [ -f /var/run/github-runners.${RUNNER_NAME} ]; then
kill "$(cat "/var/run/github-runners.${RUNNER_NAME}")"
fi
sleep ${gh_actions_sleep}
kill "$(cat "/var/run/github-runners.${RUNNER_NAME}")"
fi

# Kill the runner if it isn't in the middle of a job.
# The script will then gracefully terminate.
echo 'pkill -INT github-act-runner' | pot term -p ${RUNNER_NAME}-ephemeral >/dev/null 2>/dev/null
echo Waiting for ${RUNNER_NAME}-ephemeral to stop gracefully.
fi
fi
done
Expand Down