Repository navigation
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·78 lines (63 loc) · 1.74 KB
/
Copy pathentrypoint.sh
File metadata and controls
executable file
·78 lines (63 loc) · 1.74 KB
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
#!/bin/bash
set -o errexit
if [[ -n "$DEBUG" ]]; then
set -o xtrace
fi
services="mongodb postgresql rabbitmq-server redis-server"
function start_services () {
for name in $services; do
service $name start
done
}
function init_mongodb() {
chown --recursive mongodb:mongodb /var/lib/mongodb
local tarball_url="https://github.com/koding/koding/raw/master/install/docker-mongo/default-db-dump.tar.bz2"
curl --silent --location $tarball_url |
tar --extract --bzip2 --directory /tmp/
service mongodb start
/opt/wait.sh mongo
mongorestore /tmp/dump
rm -rf /tmp/dump
}
function init_postgresql() {
chown --recursive postgres:postgres /var/lib/postgresql
su postgres -c "/usr/lib/postgresql/9.3/bin/initdb --pgdata /var/lib/postgresql/9.3/main"
service postgresql start
su postgres -c "go/src/socialapi/db/sql/definition/create.sh go/src/socialapi/db/sql"
./run migrate up
}
function init_databases() {
[ -z "`ls --almost-all /var/lib/mongodb/`" ] && init_mongodb || :
[ -z "`ls --almost-all /var/lib/postgresql/`" ] && init_postgresql || :
}
function handle_interrupt() {
./run exec supervisorctl stop all || :
./run exec supervisorctl shutdown || :
pkill mongod
for name in $services; do
service $name stop || :
done
}
trap handle_interrupt INT TERM
function run_backend(){
init_databases
start_services
./run is_ready
./run migrate up
./run exec supervisord -c supervisord.conf
sleep 2
tail --follow --lines +0 --quiet .logs/*.log
}
if [[ -z "$*" ]]; then
./configure --host localhost --hostname localhost --publicPort 80
go/build.sh
./run exec make klient
run_backend
elif [[ "${1:0:1}" = '-' ]]; then
./configure "$@"
go/build.sh
./run exec make klient
run_backend
else
exec "$@"
fi