-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
crane / zot launcher: kill registry serve process on shell exit #421
crane / zot launcher: kill registry serve process on shell exit #421
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the cleanup procedure doesn't need to leak into call site rules. the launcher script can easily keep a global state and expose a cleanup function that kills the process.
readonly REGISTRY=$(start_registry "${STORAGE_DIR}" "${STDERR}" "${REGISTRY_PIDFILE}") The subshell (and any global state that may be preserved inside) does not survive the subshell invocation. Or to be more precise: function start_registry() {
# [...]
"${REGISTRY_BIN}" >> $output 2>&1 &
readonly REGISTRY_PID=$!
# [...]
return 0
}
function stop_registry() {
if [[ -z "${REGISTRY_PID+x}" ]]; then
echo "Registry not started"
return 0
fi
echo "Stopping registry process ${REGISTRY_PID}"
kill -9 "${REGISTRY_PID}" || true
return 0
}
# if I do this, the variable will survive but we cannot easily capture the registry address without writing to a file:
start_registry # [...] args
stop_registry
# if I do this, the variable is only part of the subshell
readonly REGISTRY=$(start_registry # [...] args)
stop_registry Proposed solutions
|
aba9214
to
a31ee09
Compare
Ah true, we can write the pid into storage_dir/proc.pid or call |
a31ee09
to
55375d5
Compare
I think pkill should not be used since it is not part of POSIX and not even in coreutils or util-linux. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff is still big and there seems to be some formatting changes. Can you revert those?
55375d5
to
df9fdd8
Compare
Sorry @malt3 going to look into this soon. |
rules_oci spawns local container registry processes and in the past, those would not be cleaned up explicitly, leading to an accumulation of processes when using remote execution with buildbarn. This pre-release contains a fix: bazel-contrib/rules_oci#421 Additionally, windows support for rules_oci was removed in this fork, since it is currently broken.
…2729) rules_oci spawns local container registry processes and in the past, those would not be cleaned up explicitly, leading to an accumulation of processes when using remote execution with buildbarn. This pre-release contains a fix: bazel-contrib/rules_oci#421 Additionally, windows support for rules_oci was removed in this fork, since it is currently broken.
Fixes #419