forked from Tencent/CodeAnalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compose_init.sh
executable file
·77 lines (66 loc) · 2.18 KB
/
compose_init.sh
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
CURRENT_PATH=$(dirname $(cd "$(dirname "$0")";pwd))
CODEDOG_DBUSER=${CODEDOG_DBUSER:-root}
CODEDOG_DBPASSWD=${CODEDOG_DBPASSWD:-'TCA!@#2021'}
function start_db() {
docker-compose up --force-recreate -d mysql redis
}
function init_db() {
db_container=$(docker-compose ps | grep mysql | awk '{print $1}')
docker-compose exec mysql /bin/bash -c \
"printf 'wait db [DB default password: TCA!@#2021]\n'; \
until \$(mysql -u${CODEDOG_DBUSER} -p'' -e '\s' > /dev/null 2>&1); do \
printf '.' && sleep 1; \
done; echo
"
}
# 文件服务器初始化
function init_file() {
mkdir -p $CURRENT_PATH/server/projects/file
docker-compose up -d file-server
docker-compose exec file-server bash -c \
"python manage.py migrate --noinput --traceback"
}
# 登陆服务器初始化
function init_login() {
mkdir -p $CURRENT_PATH/server/projects/login
docker-compose up -d login-server
docker-compose exec login-server bash -c \
"python manage.py migrate --noinput --traceback; \
python manage.py createcachetable; \
python manage.py initializedb;
"
}
# Main服务器初始化
function init_main() {
mkdir -p $CURRENT_PATH/server/projects/main/log
docker-compose up -d main-server
docker-compose exec main-server /bin/bash -c \
"python manage.py migrate --noinput --traceback; \
python manage.py createcachetable; \
python manage.py initializedb_open; \
python manage.py initialize_exclude_paths; \
python manage.py loadcheckers all --dirname open_source; \
python manage.py loadpackages all --dirname open_source_package;
"
}
# Analysis服务器初始化
function init_analysis() {
mkdir -p $CURRENT_PATH/server/projects/analysis/log
docker-compose up -d analysis-server
docker-compose exec analysis-server /bin/bash -c \
"python manage.py migrate --noinput --traceback; \
python manage.py createcachetable; \
python manage.py initialuser; \
"
}
function start_all_services() {
docker-compose up -d
}
start_db
init_db
init_file
init_login
init_analysis
init_main
start_all_services