file locking
This commit is contained in:
parent
208d91c237
commit
fb7b684cd9
|
@ -1,2 +1,3 @@
|
|||
api/api
|
||||
lxc/i
|
||||
lxc/lockfile
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
dir="$( cd "$( dirname "$0" )" && pwd )"
|
||||
|
||||
touch $dir/lockfile
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "invalid args"
|
||||
exit
|
||||
|
@ -12,7 +14,7 @@ if [ -z "$2" ]; then
|
|||
fi
|
||||
|
||||
lang=$1
|
||||
epoch=$(date +%s%3N)
|
||||
epoch=$(date +%s%N)
|
||||
basepath="/var/lib/lxc/piston/rootfs"
|
||||
filepath="/tmp/$epoch/code.code"
|
||||
argpath="/tmp/$epoch/args.args"
|
||||
|
@ -25,6 +27,8 @@ cat $2 > $basepath$filepath
|
|||
echo "${@:3}" > $basepath$argpath
|
||||
|
||||
# process incrementor
|
||||
exec 200>$dir/lockfile
|
||||
flock -x 200
|
||||
oldinc=$(cat $dir/i | awk '{$1=$1};1')
|
||||
newinc=$(expr $oldinc + 1)
|
||||
|
||||
|
@ -34,6 +38,7 @@ if (( newinc >= 151 )); then
|
|||
else
|
||||
echo $newinc > $dir/i
|
||||
fi
|
||||
exec 200>&-
|
||||
|
||||
bin=
|
||||
case "$lang" in
|
||||
|
|
|
@ -13,11 +13,11 @@ lxc-attach -n piston
|
|||
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
|
||||
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 ubuntu-make
|
||||
umake swift
|
||||
set dir to /opt
|
||||
ln -s /opt/swift/usr/bin/swift /usr/bin/swift
|
||||
set dir to /opt/swift/swift-lang
|
||||
ln -s /opt/swift/swift-lang/usr/bin/swift /usr/bin/swift
|
||||
|
||||
|
||||
# create users and apply limits
|
||||
|
|
Loading…
Reference in New Issue