add file locking to deploy/process scripts

This commit is contained in:
Daniel Micay 2022-05-05 00:15:37 -04:00
parent a255769f61
commit 43f9f22856
3 changed files with 21 additions and 1 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ nginx-tmp
node_modules node_modules
static-tmp static-tmp
releases-base releases-base
lock

View File

@ -2,7 +2,14 @@
set -o errexit -o nounset -o pipefail set -o errexit -o nounset -o pipefail
./process-static touch lock
exec {fd}< lock
if ! flock -n $fd; then
echo deploy_static already locked >&2
exit 1
fi
./process-static $fd
servers=({0..2}.grapheneos.org) servers=({0..2}.grapheneos.org)

View File

@ -3,6 +3,18 @@
set -o errexit -o nounset -o pipefail set -o errexit -o nounset -o pipefail
shopt -s dotglob extglob globstar shopt -s dotglob extglob globstar
if [[ $# -eq 1 ]]; then
fd=$1
else
touch lock
exec {fd}< lock
fi
if ! flock -n $fd; then
echo deploy_static already locked >&2
exit 1
fi
export PATH="$PWD/node_modules/.bin:$PATH" export PATH="$PWD/node_modules/.bin:$PATH"
# can use file:// to avoid network requests # can use file:// to avoid network requests