-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·72 lines (55 loc) · 1.73 KB
/
deploy.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
#! /bin/bash
cd `dirname $0`
echo $HOSTNAME
if [[ "$HOSTNAME" == isucon1 ]]; then
INSTANCE_NUM="1"
elif [[ "$HOSTNAME" == isucon2 ]]; then
INSTANCE_NUM="2"
elif [[ "$HOSTNAME" == isucon3 ]]; then
INSTANCE_NUM="3"
elif [[ "$HOSTNAME" == isucon4 ]]; then
INSTANCE_NUM="4"
elif [[ "$HOSTNAME" == isucon5 ]]; then
INSTANCE_NUM="5"
else
echo "Invalid host"
exit 1
fi
set -ex
git pull
sudo systemctl daemon-reload
# NGINX
if [[ "$INSTANCE_NUM" == 1 ]]; then
sudo install -o root -g root -m 644 ./conf/etc/nginx/sites-available/isuconquest.conf /etc/nginx/sites-available/isuconquest.conf
sudo install -o root -g root -m 644 ./conf/etc/nginx/nginx.conf /etc/nginx/nginx.conf
sudo nginx -t
sudo systemctl restart nginx
sudo systemctl enable nginx
fi
if [[ "$INSTANCE_NUM" != 1 ]]; then
sudo systemctl stop nginx.service
sudo systemctl disable nginx.service
fi
# APP
if [[ "$INSTANCE_NUM" == 1 || "$INSTANCE_NUM" == 5 ]]; then
pushd go
/home/isucon/local/golang/bin/go build -o isuconquest
popd
sudo systemctl restart isuconquest.go.service
sudo systemctl enable isuconquest.go.service
sleep 2
sudo systemctl status isuconquest.go.service --no-pager
fi
if [[ "$INSTANCE_NUM" != 1 && "$INSTANCE_NUM" != 5 ]]; then
sudo systemctl disable --now isuconquest.go.service
fi
# MYSQL
if [[ "$INSTANCE_NUM" == 2 || "$INSTANCE_NUM" == 3 || "$INSTANCE_NUM" == 4 ]]; then
sudo install -o root -g root -m 644 ./conf/etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf
echo "MySQL restart したいなら手動でやってね"
# sudo systemctl restart mysql
sudo systemctl enable --now mysql
fi
if [[ "$INSTANCE_NUM" == 1 || "$INSTANCE_NUM" == 5 ]]; then
sudo systemctl disable --now mysql.service
fi