-
Notifications
You must be signed in to change notification settings - Fork 0
/
.studiorc
165 lines (126 loc) · 3.79 KB
/
.studiorc
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
# detect source directory relative to this script
echo
echo "--> Detecting source directory..."
if [ -z "${SRC_DIR}" ]; then
SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
SRC_DIR="${SRC_DIR:-/src}"
fi
echo " SRC_DIR=${SRC_DIR}"
echo
# install busybox
echo
echo "--> Installing busybox..."
hab pkg install core/busybox-static
# install node and node-services deps
echo
echo "--> Installing node + gyp dependencies..."
hab pkg install --binlink core/node8 core/python core/make core/gcc core/git core/openssh
# for node_service_path in "${SRC_DIR}/node-services"/*/; do
# pushd "${node_service_path}" > /dev/null
# echo
# echo "--> Installing npm modules for ${node_service_path}..."
# npm install
# popd
# done
# install studio bundles
hab pkg install emergence/studio chakijs/studio
source "$(hab pkg path emergence/studio)/studio.sh"
source "$(hab pkg path chakijs/studio)/studio.sh"
# append nginx config
init-user-config --force nginx "
[http.listen]
port = 80
[default_server]
snippet = '''
include ${SRC_DIR}/node-services/*.nginx.conf;
'''
"
# configure environment for Supervisor postgres instance
export PGHOST="127.0.0.1"
export PGPORT="5432"
export PGDATABASE="postgres"
export PGUSER="admin"
export PGPASSWORD="admin"
init-user-config postgresql11 "
max_connections = 10
"
# set up postgres
export DB_CONNECTION="pgsql"
export DB_HOST="${PGHOST}"
export DB_PORT="${PGPORT}"
export DB_DATABASE="spark"
export DB_USERNAME="${PGUSER}"
export DB_PASSWORD="${PGPASSWORD}"
# start supervisor or load postgres into existing
echo
echo "--> Launching local PostgreSQL service in the background..."
hab pkg install --binlink core/postgresql11
if [ -d /hab/svc/postgresql11/data ]; then
chown hab:hab -R /hab/svc/postgresql11/data
fi
if hab svc status > /dev/null 2>&1; then
hab svc load --force core/postgresql11
else
export HAB_STUDIO_SUP=false
sup-run core/postgresql11
echo "Waiting for supervisor..."
until hab svc status 2>/dev/null >/dev/null; do
echo -n ".";
sleep .1;
done;
echo
fi
# start nats service
hab svc load core/gnatsd
# start emergence services
echo
echo "--> Launching emergence services in the background..."
start-all
echo "Waiting for runtime..."
until hab pkg exec core/busybox-static nc -z localhost 9123; do
echo -n ".";
sleep .1;
done;
sleep 1
echo
# load site
echo
echo "--> Loading emergence site from ${EMERGENCE_REPO}..."
update-site
# declare shortcuts for this repository's applications
echo
echo "--> Spark studio ready!"
echo
echo " * Use 'update-site' to rebuild entire site after changing any sources"
echo " * Use 'psql' to open PostgreSQL shell"
echo " * Use 'mysql' to open MySQL shell"
echo " * Use 'build-classroom-student' to set up SparkClassroomStudent Sencha app for live development"
build-classroom-student() {
build-app SparkClassroomStudent
}
echo " * Use 'build-classroom-teacher' to set up SparkClassroomTeacher Sencha app for live development"
build-classroom-teacher() {
build-app SparkClassroomTeacher
}
# echo " * Use 'build-dashboard-student' to build SparkDashboardStudent for testing"
# build-dashboard-student() {
# build-app SparkDashboardStudent
# }
# echo " * Use 'build-dashboard-teacher' to build SparkDashboardTeacher for testing"
# build-dashboard-teacher() {
# build-app SparkDashboardTeacher
# }
echo " * Use 'build-all' to set up all Sencha apps for live development"
build-all() {
build-classroom-student
build-classroom-teacher
# build-dashboard-student
# build-dashboard-teacher
}
echo " * Use 'reload-nginx' to reload nginx after editing ${SRC_DIR}/node-services/*.nginx.conf"
reload-nginx() {
hab pkg exec core/busybox-static killall -HUP nginx
}
# final blank line
echo