-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstart_servers.sh
executable file
·89 lines (74 loc) · 1.8 KB
/
start_servers.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
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# Check environment variables for ports, otherwise use default ports
if [ -z ${DJANGO_PORT} ]
then
django_port='8000'
else
django_port=${DJANGO_PORT}
fi
if [ -z ${SOLR_PORT} ]
then
solr_port='8983'
else
solr_port=${SOLR_PORT}
fi
if [ -z ${REDIS_PORT} ]
then
redis_port='6379'
else
redis_port=${REDIS_PORT}
fi
redis_conf=${REDIS_CONF_PATH}
pid_file="pids.txt"
verbose=$1
home_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
django_path=$home_path/django/sierra
django_start="python manage.py runserver 0.0.0.0:$django_port"
solr_path=$home_path/solr/instances
solr_start="java -jar start.jar -Djetty.port=$solr_port"
redis_path=$home_path
redis_start="redis-server $redis_conf --port $redis_port"
# check to see if servers are already running; if yes, stop them.
if [ -f $pid_file ]
then
echo "Servers are already running."
bash stop_servers.sh
wait ${!}
fi
# start Django...
cd $django_path
if [[ $verbose == "django" || $verbose == "all" ]]
then
$django_start &
else
$django_start &> /dev/null &
fi
echo "Django server started on port $django_port"
# record PID in pid_file
cd $home_path
echo "$!" > $pid_file
# start Solr...
cd $solr_path
if [[ $verbose == "solr" || $verbose == "all" ]]
then
$solr_start &
else
$solr_start &> /dev/null &
fi
echo "Solr server started on port $solr_port"
# record PID in pid_file
cd $home_path
echo "$!" >> $pid_file
# start Redis...
cd $redis_path
if [[ $verbose == "redis" || $verbose == "all" ]]
then
$redis_start &
else
$redis_start &> /dev/null &
fi
echo "Redis server started on port $redis_port"
# record PID in pid_file
cd $home_path
echo "$!" >> $pid_file
echo "Servers started in background."