-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
49 lines (36 loc) · 980 Bytes
/
docker-entrypoint.sh
File metadata and controls
49 lines (36 loc) · 980 Bytes
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
#!/bin/bash
arg1=$1
if [ -z $arg1 ]; then
exit 1
fi
check_scrapy () {
local scrapyd_exist=false
local max_retry=10
local interval=5s
local count=0
echo "Building connection with scrapy at '$SCRAPYD_URL'..."
while [[ ($scrapyd_exist == false) && ($count -lt $max_retry) ]]; do
((count++))
if ! curl -fs --connect-timeout 2 --url $SCRAPYD_URL; then
echo "Can't get connection with scrapyd. Retry after $interval. ($count/$max_retry)"
else
scrapyd_exist=true
fi
sleep $interval
done
if [ $scrapyd_exist == false ]; then
echo "Failed to build connection with scrapyd."
exit 1
else
echo "Successfully build connection with scrapyd."
fi
}
check_db () {
if ! hooktasks check db; then
echo "Can't get connection with database."
exit 1
fi
}
if [ $arg1 == "start" ]; then
check_db && check_scrapy && hooktasks run
fi