file locking
This commit is contained in:
parent
208d91c237
commit
fb7b684cd9
|
@ -1,2 +1,3 @@
|
||||||
api/api
|
api/api
|
||||||
lxc/i
|
lxc/i
|
||||||
|
lxc/lockfile
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
dir="$( cd "$( dirname "$0" )" && pwd )"
|
dir="$( cd "$( dirname "$0" )" && pwd )"
|
||||||
|
|
||||||
|
touch $dir/lockfile
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "invalid args"
|
echo "invalid args"
|
||||||
exit
|
exit
|
||||||
|
@ -12,7 +14,7 @@ if [ -z "$2" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lang=$1
|
lang=$1
|
||||||
epoch=$(date +%s%3N)
|
epoch=$(date +%s%N)
|
||||||
basepath="/var/lib/lxc/piston/rootfs"
|
basepath="/var/lib/lxc/piston/rootfs"
|
||||||
filepath="/tmp/$epoch/code.code"
|
filepath="/tmp/$epoch/code.code"
|
||||||
argpath="/tmp/$epoch/args.args"
|
argpath="/tmp/$epoch/args.args"
|
||||||
|
@ -25,6 +27,8 @@ cat $2 > $basepath$filepath
|
||||||
echo "${@:3}" > $basepath$argpath
|
echo "${@:3}" > $basepath$argpath
|
||||||
|
|
||||||
# process incrementor
|
# process incrementor
|
||||||
|
exec 200>$dir/lockfile
|
||||||
|
flock -x 200
|
||||||
oldinc=$(cat $dir/i | awk '{$1=$1};1')
|
oldinc=$(cat $dir/i | awk '{$1=$1};1')
|
||||||
newinc=$(expr $oldinc + 1)
|
newinc=$(expr $oldinc + 1)
|
||||||
|
|
||||||
|
@ -34,6 +38,7 @@ if (( newinc >= 151 )); then
|
||||||
else
|
else
|
||||||
echo $newinc > $dir/i
|
echo $newinc > $dir/i
|
||||||
fi
|
fi
|
||||||
|
exec 200>&-
|
||||||
|
|
||||||
bin=
|
bin=
|
||||||
case "$lang" in
|
case "$lang" in
|
||||||
|
|
|
@ -13,11 +13,11 @@ lxc-attach -n piston
|
||||||
export PATH=/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
|
export PATH=/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
|
||||||
sed -i 's/http:\/\/archive.ubuntu.com\/ubuntu/http:\/\/mirror.math.princeton.edu\/pub\/ubuntu/' /etc/apt/sources.list
|
sed -i 's/http:\/\/archive.ubuntu.com\/ubuntu/http:\/\/mirror.math.princeton.edu\/pub\/ubuntu/' /etc/apt/sources.list
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get -y install ubuntu-make
|
|
||||||
apt-get -y install git tzdata nano dpkg-dev build-essential python python3 ruby nodejs golang php7.2 r-base mono-complete nasm openjdk-8-jdk
|
apt-get -y install git tzdata nano dpkg-dev build-essential python python3 ruby nodejs golang php7.2 r-base mono-complete nasm openjdk-8-jdk
|
||||||
|
apt-get -y install ubuntu-make
|
||||||
umake swift
|
umake swift
|
||||||
set dir to /opt
|
set dir to /opt/swift/swift-lang
|
||||||
ln -s /opt/swift/usr/bin/swift /usr/bin/swift
|
ln -s /opt/swift/swift-lang/usr/bin/swift /usr/bin/swift
|
||||||
|
|
||||||
|
|
||||||
# create users and apply limits
|
# create users and apply limits
|
||||||
|
|
Loading…
Reference in New Issue