-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrun-nginx-server
executable file
·77 lines (64 loc) · 2.71 KB
/
run-nginx-server
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
#!/usr/bin/env bash
. ./scripts/devcontainer/_assert-in-container "$0" "$@"
##################
## Kill running nginx server or we won't be able to start it again
##################
sudo killall nginx
sudo killall -9 nginx
sudo rm -f /var/log/nginx/*.log
until [[ "$(sudo netstat -ltnp | grep -w ':9000')" == "" ]]; do
echo "Waiting for nginx (apiserver) to die..."
sleep 0.1
done
##################
# Set up each server individually, not sharing config, to match production
##################
setup() {
name=$1
source=$2
config_file=$3
sudo rm -Rf /etc/nginx-$name/
sudo mkdir -p /etc/nginx-$name/conf.d
sudo cp /home/dark/app/$config_file /etc/nginx-$name/nginx.conf
sudo cp /home/dark/app/$source/nginx.conf /etc/nginx-$name/conf.d/$name-nginx.conf
# Two log per server, in rundir
sudo sed -i /etc/nginx-$name/nginx.conf -e "s/error\.log/$name-error.log/" -e "s/access\.log/$name-access.log/"
sudo rm -f /home/dark/app/rundir/logs/nginx-$name-access.log
ln -s /var/log/nginx/$name-access.log /home/dark/app/rundir/logs/nginx-$name-access.log
sudo rm -f /home/dark/app/rundir/logs/nginx-$name-error.log
ln -s /var/log/nginx/$name-error.log /home/dark/app/rundir/logs/nginx-$name-error.log
echo "Starting nginx ($name)"
sudo nginx -c /etc/nginx-$name/nginx.conf
echo "Started nginx ($name)"
}
setup_test() {
name=$1
source=$2
config_file=$3
listen_port=$4
new_listen_port=$5
upstream_port=$6
new_upstream_port=$7
sudo rm -Rf /etc/nginx-test-$name/
sudo mkdir -p /etc/nginx-test-$name/conf.d
sudo cp /home/dark/app/$config_file /etc/nginx-test-$name/nginx.conf
sudo cp /home/dark/app/$source/nginx.conf /etc/nginx-test-$name/conf.d/test-$name-nginx.conf
# Two log per server, in rundir
sudo sed -i /etc/nginx-test-$name/nginx.conf \
-e "s/error\.log/test-$name-error.log/" \
-e "s/access\.log/test-$name-access.log/"
sudo rm -f /home/dark/app/rundir/logs/nginx-test-$name-access.log
ln -s /var/log/nginx/test-$name-access.log /home/dark/app/rundir/logs/nginx-test-$name-access.log
sudo rm -f /home/dark/app/rundir/logs/nginx-test-$name-error.log
ln -s /var/log/nginx/test-$name-error.log /home/dark/app/rundir/logs/nginx-test-$name-error.log
# Use a test port
sudo sed -i /etc/nginx-test-$name/conf.d/test-$name-nginx.conf \
-e "s/$listen_port/$new_listen_port/g" \
-e "s/$upstream_port/$new_upstream_port/g"
echo "Starting nginx (test-$name)"
sudo nginx -c /etc/nginx-test-$name/nginx.conf
echo "Started nginx (test-$name)"
}
sudo rm -f /etc/nginx/nginx.conf
setup apiserver services/apiserver-deployment-darklang/ containers/base-fsharp-nginx.conf
setup_test apiserver services/apiserver-deployment-darklang/ containers/base-fsharp-nginx.conf 9000 10020 9001 10021