nixpkgs-update: shellcheck, shfmt worker script
This commit is contained in:
parent
e37d6f9f6c
commit
a3109acfde
1 changed files with 28 additions and 27 deletions
|
@ -1,6 +1,6 @@
|
||||||
mkdir -p "$LOGS_DIRECTORY/~workers/"
|
mkdir -p "$LOGS_DIRECTORY/~workers/"
|
||||||
# This is for public logs at nixpkgs-update-logs.nix-community.org/~workers
|
# This is for public logs at nixpkgs-update-logs.nix-community.org/~workers
|
||||||
exec > >(rotatelogs -eD "$LOGS_DIRECTORY/~workers/%Y-%m-%d-${WORKER_NAME}.stdout.log" 86400)
|
exec > >(rotatelogs -eD "$LOGS_DIRECTORY/~workers/%Y-%m-%d-${WORKER_NAME}.stdout.log" 86400)
|
||||||
exec 2> >(rotatelogs -eD "$LOGS_DIRECTORY/~workers/%Y-%m-%d-${WORKER_NAME}.stderr.log" 86400 >&2)
|
exec 2> >(rotatelogs -eD "$LOGS_DIRECTORY/~workers/%Y-%m-%d-${WORKER_NAME}.stderr.log" 86400 >&2)
|
||||||
|
|
||||||
socket=/run/nixpkgs-update-supervisor/work.sock
|
socket=/run/nixpkgs-update-supervisor/work.sock
|
||||||
|
@ -20,32 +20,33 @@ msg=READY
|
||||||
while true; do
|
while true; do
|
||||||
response=$(echo "$msg" | socat -t5 UNIX-CONNECT:"$socket" - || true)
|
response=$(echo "$msg" | socat -t5 UNIX-CONNECT:"$socket" - || true)
|
||||||
case "$response" in
|
case "$response" in
|
||||||
"") # connection error; retry
|
"") # connection error; retry
|
||||||
sleep 5
|
sleep 5
|
||||||
;;
|
;;
|
||||||
NOJOBS)
|
NOJOBS)
|
||||||
msg=READY
|
msg=READY
|
||||||
sleep 60
|
sleep 60
|
||||||
;;
|
;;
|
||||||
JOB\ *)
|
JOB\ *)
|
||||||
read -r attr_path payload <<< "${response#JOB }"
|
read -r attr_path payload <<<"${response#JOB }"
|
||||||
# If one worker is initializing the nixpkgs clone, the other will
|
# If one worker is initializing the nixpkgs clone, the other will
|
||||||
# try to use the incomplete clone, consuming a bunch of jobs and
|
# try to use the incomplete clone, consuming a bunch of jobs and
|
||||||
# throwing them away. So we use a crude locking mechanism to
|
# throwing them away. So we use a crude locking mechanism to
|
||||||
# run only one worker when there isn't a nixpkgs directory yet.
|
# run only one worker when there isn't a nixpkgs directory yet.
|
||||||
# Once the directory exists and this initial lock is released,
|
# Once the directory exists and this initial lock is released,
|
||||||
# multiple workers can run concurrently.
|
# multiple workers can run concurrently.
|
||||||
lockdir="$XDG_CACHE_HOME/.nixpkgs.lock"
|
lockdir="$XDG_CACHE_HOME/.nixpkgs.lock"
|
||||||
if [ ! -e "$XDG_CACHE_HOME/nixpkgs" ] && mkdir "$lockdir"; then
|
if [ ! -e "$XDG_CACHE_HOME/nixpkgs" ] && mkdir "$lockdir"; then
|
||||||
trap 'rmdir "$lockdir"' EXIT
|
trap 'rmdir "$lockdir"' EXIT
|
||||||
run-nixpkgs-update
|
|
||||||
rmdir "$lockdir"
|
|
||||||
trap - EXIT
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
while [ -e "$lockdir" ]; do
|
|
||||||
sleep 10
|
|
||||||
done
|
|
||||||
run-nixpkgs-update
|
run-nixpkgs-update
|
||||||
|
rmdir "$lockdir"
|
||||||
|
trap - EXIT
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
while [ -e "$lockdir" ]; do
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
run-nixpkgs-update
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Reference in a new issue