-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconcc-exec
executable file
·52 lines (45 loc) · 1.04 KB
/
concc-exec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
if [ "$CONCC_DEBUG_EXEC" = 1 ]
then
set -ex
fi
if [ -x /opt/concc/scripts/exec-local ]
then
if /opt/concc/scripts/exec-local "$@"
then
# This is a dirty hack...
#
# Some of programs may replace with concc-exec wrapper scripts in the
# setup-client script. Set CONCC_EXEC_LOCAL 1 in order to invoke the
# original program and prevent infinite recursive calls.
exec env CONCC_EXEC_LOCAL=1 "$@"
fi
fi
SLEEP=${CONCC_DEFAULT_SLEEP:-5}
WORKER=
release() {
if [ -n "$SCRIPT_FILE" ]
then
/bin/rm -f $SCRIPT_FILE
fi
if [ -n "$WORKER" ]
then
concc-worker-pool release $WORKER
fi
}
trap release EXIT INT TERM
while true
do
WORKER=$(concc-worker-pool allocate)
if [ -n "$WORKER" ]
then
break
fi
sleep $SLEEP
done
WORKER_HOST=$(echo $WORKER | cut -d ':' -f 1)
WORKER_PORT=$(echo $WORKER | cut -d ':' -f 2)
mkdir -p /workspace/.concc.d/tasks
SCRIPT_FILE=$(mktemp -p /workspace/.concc.d/tasks task.XXX)
concc-scriptify "$@" >$SCRIPT_FILE
ssh -p $WORKER_PORT root@$WORKER_HOST sh $SCRIPT_FILE