-
Notifications
You must be signed in to change notification settings - Fork 4
/
vip.bsh
executable file
·388 lines (316 loc) · 19 KB
/
vip.bsh
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
#!/bin/bash
export VIP_PROJECT_DIR=${VIP_PROJECT_DIR-$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)}
if [ -e "${VIP_PROJECT_DIR}/conf/vip.env" ]; then
source "${VIP_PROJECT_DIR}/conf/vip.env"
fi
export VIP_LOCAL_SETTINGS=${VIP_LOCAL_SETTINGS-${VIP_PROJECT_DIR}/local_vip.env}
export VIP_LOCAL_SETTINGS_POST=${VIP_LOCAL_SETTINGS_POST-${VIP_PROJECT_DIR}/local_vip_post.env}
#Source first to pre-override everything
if [ -e "${VIP_LOCAL_SETTINGS}" ]; then
source "${VIP_LOCAL_SETTINGS}"
else
echo "#Put local setting in this file" > "${VIP_LOCAL_SETTINGS}"
fi
export VIP_OS=${VIP_OS-`uname -s`}
export VIP_ARCH=${VIP_ARCH-`uname -m`}
#### OS Specific settings ###
if [ "${VIP_OS}" == "Linux" ]; then
: ${VIP_NUMBER_CORES=$(nproc)}
elif [ "${VIP_OS}" == "Darwin" ]; then
: ${VIP_NUMBER_CORES=$(sysctl -n hw.ncpu)}
else #WINDOWS!!!
export VIP_OS=Windows
: ${VIP_NUMBER_CORES=${NUMBER_OF_PROCESSORS}}
: ${VIP_POSTGRESQL_DIR=vip_postgresql}
: ${VIP_STORAGE_DIR=vip_storage}
: ${VIP_IMAGE_DIR=vip_image}
fi
export VIP_NUMBER_CORES
function set_temp_array()
{ # 1 - source_array_name $2-* default_values
local default="$1"
shift
if declare -p $default >& /dev/null; then
default="${default}[@]"
VIP_TEMP_VAR=(${!default+"${!default}"})
else
VIP_TEMP_VAR=(${@+"${@}"})
fi
}
#### Basic Settings ###
export VIP_PROJECT_NAME=${VIP_PROJECT_NAME-voxel_globe}
export VIP_WRAP_SCRIPT=${VIP_WRAP_SCRIPT-${VIP_PROJECT_DIR}/wrap}
export VIP_BUILD=${VIP_BUILD-${VIP_OS}_${VIP_ARCH}}
export VIP_EMAIL=${VIP_EMAIL-email@example.com}
vip_admin_email_set=${VIP_ADMIN_EMAIL:+SET}
export VIP_ADMIN_EMAIL=${VIP_ADMIN_EMAIL-admin@example.com}
export VIP_HOSTNAME=${VIP_HOSTNAME-localhost}
#### Debug Flags ###
export VIP_DEBUG=${VIP_DEBUG-0}
#This flags should ONLY be used in the following lines. Please create a new
#Debug flag every time you need it. VIP_DEBUG is just an easy way to disable
#or enable them all at once.
export VIP_DJANGO_DEBUG=${VIP_DJANGO_DEBUG-${VIP_DEBUG}}
export VIP_DJANGO_TEMPLATE_DEBUG=${VIP_DJANGO_TEMPLATE_DEBUG-${VIP_DEBUG}}
export VIP_CELERY_AUTORELOAD=${VIP_CELERY_AUTORELOAD-${VIP_DEBUG}}
export VIP_CELERY_DJANGO_DEBUG=${VIP_CELERY_DJANGO_DEBUG-0}
#Special flag to attempt to disable django debug when loaded by celery.
#HOPEFULLY this allows the django server server by uwsgi to be in debug
#mode while the django loaded in celery is not. This should prevent the
#memory leak in celery while still making debugging bearable
export VIP_TEMP_KEEP=${VIP_TEMP_KEEP-0}
#This flag disables temp directory cleanup. It is useful when you want to
#debug/inspect the contents of a temporary directory from a processing job
#Only works with tasks that correctly use
# "with voxel_globe.tools.task_dir():"
export VIP_CONSTANT_TEMP_DIR=${VIP_CONSTANT_TEMP_DIR-0}
#Very useful for debugging. Everything dumped into VIP_TEMP_DIR directly, instead of a random dir inside
export VIP_START_MANAGE_PORT=${VIP_START_MANAGE_PORT-8000}
export VIP_START_MANAGE_DOCK_PORT=${VIP_START_MANAGE_DOCK_PORT-8000}
export VIP_GDBSERVER_PORT=3333 #used internal dockers only. External is random
export VIP_GDBSERVER=${VIP_GDBSERVER-${VIP_DEBUG}} #Set up gdbserver
#### DIR Settings ###
export VIP_CONF_DIR=${VIP_CONF_DIR-${VIP_PROJECT_DIR}/conf}
export VIP_LOG_DIR=${VIP_LOG_DIR-${VIP_PROJECT_DIR}}
#Currently only Linux even uses the lock dir
export VIP_DATA_DIR=${VIP_DATA_DIR-${VIP_PROJECT_DIR}/data}
export VIP_EXTERNAL_DATA_DIR=${VIP_EXTERNAL_DATA_DIR-${VIP_PROJECT_DIR}/external/data}
export VIP_STORAGE_DIR=${VIP_STORAGE_DIR-${VIP_DATA_DIR}/storage}
export VIP_IMAGE_DIR=${VIP_IMAGE_DIR-${VIP_DATA_DIR}/images}
export VIP_TEMP_DIR=${VIP_TEMP_DIR-/tmp}
export VIP_VSI_DIR=${VIP_VSI_DIR-${VIP_PROJECT_DIR}/external/vsi}
#### Vxl Settings ###
export VIP_VXL_BUILD_TYPE=${VIP_VXL_BUILD_TYPE-Release}
export VIP_VXL_CMAKE_ENTRIES=${VIP_VXL_CMAKE_ENTRIES-"-DBUILD_BRL_PYTHON=1 -DBUILD_VGUI=1 -DCMAKE_BUILD_TYPE=${VIP_VXL_BUILD_TYPE}"}
export VIP_VXL_SRC_DIR=${VIP_VXL_SRC_DIR-${VIP_PROJECT_DIR}/external/vxl_src}
export VIP_OPENCL_DEVICE=${VIP_OPENCL_DEVICE-cpu0}
#### Notebook settings ###
export VIP_NOTEBOOK_PORT=${VIP_NOTEBOOK_PORT-8888}
export VIP_NOTEBOOK_IP=${VIP_NOTEBOOK_IP-0.0.0.0}
export VIP_NOTEBOOK_DIR=${VIP_NOTEBOOK_DIR-~/notebooks}
export VIP_NOTEBOOK_CONFIG_DIR=${VIP_NOTEBOOK_CONFIG_DIR-${VIP_NOTEBOOK_DIR}/.config}
export VIP_NOTEBOOK_CUSTOM_DIR=${VIP_NOTEBOOK_CUSTOM_DIR-${VIP_NOTEBOOK_DIR}/.custom}
#### Django settings ###
export VIP_DJANGO_PROJECT=${VIP_DJANGO_PROJECT-${VIP_PROJECT_DIR}/voxel_globe}
#I am adding the namespace voxel_globe to ALL web content, so this and celery_processors will eventual be merged into JUST VIP_PROJECT_DIR, and that will be the only thing added to pythonpath in env.bat
export VIP_DJANGO_SITE=${VIP_DJANGO_SITE-${VIP_DJANGO_PROJECT}/vip}
export VIP_DJANGO_STATIC_DIR=${VIP_DJANGO_STATIC_DIR-${VIP_PROJECT_DIR}/static_deploy}
export VIP_DJANGO_SETTINGS_MODULE=${VIP_DJANGO_SETTINGS_MODULE-voxel_globe.vip.settings}
export VIP_DJANGO_STATIC_URL_PATH=${VIP_DJANGO_STATIC_URL_PATH-/static}
export VIP_DJANGO_STATIC_COMMON=${VIP_DJANGO_STATIC_COMMON-${VIP_DJANGO_PROJECT}/static_common}
export VIP_DJANGO_MEDIA_DIR=${VIP_DJANGO_MEDIA_DIR-${VIP_DJANGO_PROJECT}/media_root}
#Note: Since environment variables are process-wide, this doesn't work when you
#run multiple Django sites in the same process. This can happen with mod_wsgi.
#To avoid this problem, use mod_wsgi’s daemon mode with each site in its own daemon
#process, or override the value from the environment by enforcing
#os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings" in your wsgi.py.
export VIP_DJANGO_REGRESSION_APP=${VIP_DJANGO_REGRESSION_APP-world}
export VIP_DJANGO_REGRESSION_SHAPEFILE=${VIP_DJANGO_REGRESSION_SHAPEFILE-${VIP_EXTERNAL_DATA_DIR}/TM_WORLD_BORDERS-0.3.zip}
export VIP_DJANGO_ADMIN_USER=${VIP_DJANGO_ADMIN_USER-vip}
export VIP_DJANGO_PASSWD=${VIP_DJANGO_PASSWD-${VIP_PROJECT_DIR}/shadow/django}
export VIP_DJANGO_ALLOWED_HOSTS=${VIP_DJANGO_ALLOWED_HOSTS-['*']}
#### POSTGRESQL Settings ###
export VIP_INITIALIZE_DATABASE_CONFIRM=${VIP_INITIALIZE_DATABASE_CONFIRM-1}
#Does not work yet, need to upgrade postgres image to use POSTGRES_INITDB_ARGS
#I don't NEED to fix this currently, as the defaults are what I want
#export VIP_POSTGRESQL_INITDB_ARGS='--encoding UTF8 --locale en_US.UTF-8'
#For connecting
export VIP_POSTGRESQL_HOST=${VIP_POSTGRESQL_HOST_HOST-${VIP_HOSTNAME}}
export VIP_POSTGRESQL_PORT=${VIP_POSTGRESQL_HOST_PORT-5432}
export VIP_POSTGRESQL_PUBLISH=${VIP_POSTGRESQL_PUBLISH-0} #Publish port outside docker
#set VIP_POSTGRESQL_USER=vip_postgresql REM AEN Obviously I still don't understand this still
export VIP_POSTGRESQL_USER=${VIP_POSTGRESQL_USER-postgres} #should NOT be changed without rewriting docker image
export VIP_POSTGRESQL_PASSWORD=${VIP_POSTGRESQL_PASSWORD-changeme} #Not used yet
#TODO use pgpass instead
export VIP_POSTGRESQL_DATABASE_NAME=${VIP_POSTGRESQL_DATABASE_NAME-geodjango}
export VIP_POSTGRESQL_DIR=${VIP_POSTGRESQL_DIR-${VIP_DATA_DIR}/postgresql}
#### Celery Settings ###
export VIP_CELERY_LOG_LEVEL=${VIP_CELERY_LOG_LEVEL-INFO}
export VIP_CELERY_WORKER_LOG_LEVEL=${VIP_CELERY_LOG_LEVEL-INFO}
export VIP_CELERY_APP=${VIP_CELERY_APP-voxel_globe.vip}
export VIP_CELERY_DBSTOP_IF_ERROR=${VIP_CELERY_DBSTOP_IF_ERROR-0}
export VIP_CELERY_DEFAULT_EXCHANGE=${VIP_CELERY_DEFAULT_EXCHANGE-vip_exchange}
export VIP_CELERY_DEFAULT_QUEUE=${VIP_CELERY_DEFAULT_QUEUE-vip_queue}
#Make sure all of these have the same length
export VIP_CELERY_QUEUES=${VIP_CELERY_QUEUES-"['${VIP_CELERY_DEFAULT_QUEUE}', 'vip_gpu']"}
export VIP_CELERY_EXCHANGES=${VIP_CELERY_EXCHANGES-"['${VIP_CELERY_DEFAULT_EXCHANGE}', '${VIP_CELERY_DEFAULT_EXCHANGE}']"}
export VIP_CELERY_KEYS=${VIP_CELERY_KEYS-'["vip_default", "gpu"]'}
#Flower
export VIP_FLOWER_HOST=${VIP_FLOWER_HOST-${VIP_HOSTNAME}}
export VIP_FLOWER_PORT=${VIP_FLOWER_PORT-5555}
#### NGINX Server ####
export VIP_NGINX_CONF=${VIP_NGINX_CONF-${VIP_CONF_DIR}/nginx.conf}
export VIP_NGINX_PORT=${VIP_NGINX_PORT-80}
export VIP_NGINX_SSL_PORT=${VIP_NGINX_SSL_PORT-443}
export VIP_NGINX_PORT_DOCK=${VIP_NGINX_PORT_DOCK-80}
export VIP_NGINX_SSL_PORT_DOCK=${VIP_NGINX_SSL_PORT_DOCK-443}
export VIP_NGINX_SSL_DIR_DOCK=${VIP_NGINX_SSL_DIR_DOCK-/etc/letsencrypt}
export VIP_MANAGE_SERVER=0 #Do not change this, it's for manage.py use only
export VIP_LETSENCRYPT_DOMAINNAME=${VIP_LETSENCRYPT_DOMAINNAME-0}
if [ "${VIP_LETSENCRYPT_DOMAINNAME}" != "0" ]; then
#This is going to be an annoy message seen EVERYWHERE
if [ ! "${vip_admin_email_set}" == "SET" ]; then
echo "WARNING: Using Let's Encrypt without setting VIP_ADMIN_EMAIL is a bad idea" 1>&2
fi
if [ -f "${VIP_NGINX_SSL_DIR_DOCK}/live/${VIP_LETSENCRYPT_DOMAINNAME}/fullchain.pem" ]; then
export VIP_NGINX_SSL_CERT=${VIP_NGINX_SSL_CERT-${VIP_NGINX_SSL_DIR_DOCK}/live/${VIP_LETSENCRYPT_DOMAINNAME}/fullchain.pem}
else
export VIP_NGINX_SSL_CERT=${VIP_NGINX_SSL_CERT-${VIP_CONF_DIR}/server.crt}
fi
if [ -f "${VIP_NGINX_SSL_DIR_DOCK}/live/${VIP_LETSENCRYPT_DOMAINNAME}/privkey.pem" ]; then
export VIP_NGINX_SSL_KEY=${VIP_NGINX_SSL_KEY-${VIP_NGINX_SSL_DIR_DOCK}/live/${VIP_LETSENCRYPT_DOMAINNAME}/privkey.pem}
else
export VIP_NGINX_SSL_KEY=${VIP_NGINX_SSL_KEY-${VIP_CONF_DIR}/server.key}
fi
export VIP_NGINX_HOSTNAME=${VIP_NGINX_HOSTNAME-${VIP_LETSENCRYPT_DOMAINNAME}}
else
export VIP_NGINX_SSL_CERT=${VIP_NGINX_SSL_CERT-${VIP_CONF_DIR}/server.crt}
export VIP_NGINX_SSL_KEY=${VIP_NGINX_SSL_KEY-${VIP_CONF_DIR}/server.key}
export VIP_NGINX_HOSTNAME=${VIP_NGINX_HOSTNAME-${VIP_HOSTNAME}}
fi
export VIP_NGINX_XSENDFILE_PREFIX=${VIP_NGINX_XSENDFILE_PREFIX-/protected}
#### Image Server Settings ###
export VIP_IMAGE_SERVER_PROTOCOL=${VIP_IMAGE_SERVER_PROTOCOL-https}
export VIP_IMAGE_SERVER_HOST=${VIP_IMAGE_SERVER_HOST-localhost}
export VIP_IMAGE_SERVER_PORT=${VIP_IMAGE_SERVER_PORT-${VIP_NGINX_SSL_PORT}}
export VIP_IMAGE_SERVER_URL_PATH=${VIP_IMAGE_SERVER_URL_PATH-/images}
export VIP_IMAGE_SERVER_DIFFERENT=${VIP_IMAGE_SERVER_DIFFERENT-0}
#Where are the images served from
export VIP_IMAGE_SERVER_CHECKSUM_DEPTH=${VIP_IMAGE_SERVER_CHECKSUM_DEPTH-2}
#How many checksum hexits directories to create, 2 means b2/54/b254b34542cae...
#For the initial wsgi.py file and all Celery processors
export VIP_WSGI_SCRIPT_ALIAS=${VIP_WSGI_SCRIPT_ALIAS-${VIP_DJANGO_SITE}/wsgi.py}
export VIP_WSGI_ACCESS_SCRIPT=${VIP_WSGI_ACCESS_SCRIPT-${VIP_DJANGO_SITE}/auth.py}
#########################################################################
############################ Docker settings ############################
#########################################################################
export VIP_IN_DOCKER=${VIP_IN_DOCKER-0}
export VIP_DOCKER_REPO=${VIP_DOCKER_REPO-vsiri/voxel_globe}
#PUBREL make vsiri/voxel_globe with public release
export VIP_DOCKER_NETWORK=${VIP_DOCKER_NETWORK-voxel_globe}
export VIP_DOCKER_DELETE_VOLUME_ON_RESET=${VIP_DOCKER_DELETE_VOLUME_ON_RESET-1}
export VIP_DOCKER_USER_ID=${VIP_DOCKER_USER_ID-`id -u`}
export VIP_DOCKER_GROUP_ID=${VIP_DOCKER_GROUP_ID-`id -g`}
export VIP_DOCKER_COMMON_IMAGE_NAME=${VIP_DOCKER_COMMON_IMAGE_NAME-${VIP_DOCKER_REPO}:common}
export VIP_DOCKER_POSTGRES_IMAGE_NAME=${VIP_DOCKER_POSTGRES_IMAGE_NAME-${VIP_DOCKER_REPO}:postgresql}
export VIP_DOCKER_RABBITMQ_IMAGE_NAME=${VIP_DOCKER_RABBITMQ_IMAGE_NAME-${VIP_DOCKER_REPO}:rabbitmq}
export VIP_DOCKER_CELERY_IMAGE_NAME=${VIP_DOCKER_CELERY_IMAGE_NAME-${VIP_DOCKER_REPO}:celery}
export VIP_DOCKER_FLOWER_IMAGE_NAME=${VIP_DOCKER_FLOWER_IMAGE_NAME-${VIP_DOCKER_REPO}:flower}
export VIP_DOCKER_NOTEBOOK_IMAGE_NAME=${VIP_DOCKER_NOTEBOOK_IMAGE_NAME-${VIP_DOCKER_REPO}:notebook}
export VIP_DOCKER_NGINX_IMAGE_NAME=${VIP_DOCKER_NGINX_IMAGE_NAME-${VIP_DOCKER_REPO}:nginx}
export VIP_DOCKER_UWSGI_IMAGE_NAME=${VIP_DOCKER_UWSGI_IMAGE_NAME-${VIP_DOCKER_REPO}:uwsgi}
export VIP_DOCKER_VXL_IMAGE_NAME=${VIP_DOCKER_VXL_IMAGE_NAME-${VIP_DOCKER_REPO}:vxl}
export VIP_DOCKER_REDIS_IMAGE_NAME=${VIP_DOCKER_REDIS_IMAGE_NAME-${VIP_DOCKER_REPO}:redis}
export VIP_DOCKER_DAPHNE_IMAGE_NAME=${VIP_DOCKER_DAPHNE_IMAGE_NAME-${VIP_DOCKER_REPO}:daphne}
export VIP_DOCKER_ASGI_IMAGE_NAME=${VIP_DOCKER_ASGI_IMAGE_NAME-${VIP_DOCKER_REPO}:asgi}
export VIP_DOCKER_CONTAINER_NAME_PREFIX=${VIP_DOCKER_CONTAINER_NAME_PREFIX-vip}
export VIP_DOCKER_POSTGRES_CONTAINER_NAME=${VIP_DOCKER_POSTGRES_CONTAINER_NAME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}-postgresql}
export VIP_DOCKER_RABBITMQ_CONTAINER_NAME=${VIP_DOCKER_RABBITMQ_CONTAINER_NAME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}-rabbitmq}
export VIP_DOCKER_CELERY_CONTAINER_NAME=${VIP_DOCKER_CELERY_CONTAINER_NAME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}-celery}
export VIP_DOCKER_FLOWER_CONTAINER_NAME=${VIP_DOCKER_FLOWER_CONTAINER_NAME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}-flower}
export VIP_DOCKER_NOTEBOOK_CONTAINER_NAME=${VIP_DOCKER_NOTEBOOK_CONTAINER_NAME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}-notebook}
export VIP_DOCKER_NGINX_CONTAINER_NAME=${VIP_DOCKER_NGINX_CONTAINER_NAME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}-nginx}
export VIP_DOCKER_UWSGI_CONTAINER_NAME=${VIP_DOCKER_UWSGI_CONTAINER_NAME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}-uwsgi}
export VIP_DOCKER_REDIS_CONTAINER_NAME=${VIP_DOCKER_REDIS_CONTAINER_NAME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}-redis}
export VIP_DOCKER_DAPHNE_CONTAINER_NAME=${VIP_DOCKER_DAPHNE_CONTAINER_NAME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}-daphne}
export VIP_DOCKER_ASGI_CONTAINER_NAME=${VIP_DOCKER_ASGI_CONTAINER_NAME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}-asgi}
export VIP_DOCKER_USE_NOTEBOOK=${VIP_DOCKER_USE_NOTEBOOK-${VIP_DEBUG}}
# Dirs
export VIP_IMAGE_DIR_DOCK=${VIP_IMAGE_DIR_DOCK-/images}
export VIP_STORAGE_DIR_DOCK=${VIP_STORAGE_DIR_DOCK-/storage}
export VIP_PROJECT_DIR_DOCK=${VIP_PROJECT_DIR_DOCK-/opt/vip}
# Postgresql
export VIP_POSTGRESQL_HOST_DOCK=${VIP_POSTGRESQL_HOST_DOCK-vip-postgresql}
export VIP_POSTGRESQL_PORT_DOCK=${VIP_POSTGRESQL_PORT_DOCK-5432}
export VIP_POSTGRESQL_CREDENTIALS_DOCK=${VIP_POSTGRESQL_CREDENTIALS_DOCK--U ${VIP_POSTGRESQL_USER} -h ${VIP_POSTGRESQL_HOST_DOCK} -p ${VIP_POSTGRESQL_PORT_DOCK}}
export VIP_POSTGRESQL_DIR_DOCK=${VIP_POSTGRESQL_DIR_DOCK-/var/lib/postgresql/data}
# Rabbitmq
export VIP_RABBITMQ_HOST_DOCK=${VIP_RABBITMQ_HOST_DOCK-vip-rabbitmq}
export VIP_RABBITMQ_VOLUME=${VIP_RABBITMQ_VOLUME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}_rabbitmq}
export VIP_RABBITMQ_DIR_DOCK=${VIP_RABBITMQ_DIR_DOCK-/var/lib/rabbitmq}
# Celery
export VIP_CELERY_BROKER_URL_DOCK=${VIP_CELERY_BROKER_URL_DOCK-amqp://guest@${VIP_RABBITMQ_HOST_DOCK}:5672//}
VIP_DOCKER_CELERY_IMAGE_NAMES=(${VIP_DOCKER_CELERY_IMAGE_NAME})
#Setting up multiple processing nodes
if [ "${VIP_OS}" == "Linux" ] && which nvidia-docker >& /dev/null; then
#GPU configuration!!!!
VIP_TEMP_VAR=(default gpu)
VIP_CELERY_NODES=("${VIP_CELERY_NODES-${VIP_TEMP_VAR[@]}}")
#Add image name to list so it is pulled and pushed correctly
VIP_DOCKER_CELERY_IMAGE_NAMES+=(${VIP_DOCKER_CELERY_IMAGE_NAME}_gpu)
#Individual arguments for specific nodes
set_temp_array VIP_CELERY_DEFAULT_ARGS -e VIP_CELERY_ARGS="-Q ${VIP_CELERY_DEFAULT_QUEUE}"
VIP_CELERY_DEFAULT_ARGS=(${VIP_TEMP_VAR+"${VIP_TEMP_VAR[@]}"})
set_temp_array VIP_CELERY_ARGS_gpu -e VIP_OPENCL_DEVICE=${VIP_OPENCL_DEVICE_gpu-gpu0} -e VIP_CELERY_ARGS="-Q vip_gpu"
VIP_CELERY_ARGS_gpu=(${VIP_TEMP_VAR+"${VIP_TEMP_VAR[@]}"})
else #No gpu configuration
set_temp_array VIP_CELERY_NODES default
VIP_CELERY_NODES=(${VIP_TEMP_VAR+"${VIP_TEMP_VAR[@]}"})
#Individual arguments for specific nodes
set_temp_array VIP_CELERY_DEFAULT_ARGS
VIP_CELERY_DEFAULT_ARGS=(${VIP_TEMP_VAR+"${VIP_TEMP_VAR[@]}"})
fi
# Flower
export VIP_FLOWER_PORT_DOCK=${VIP_FLOWER_PORT_DOCK-5555}
# Notebook
export VIP_NOTEBOOK_PORT_DOCK=${VIP_NOTEBOOK_PORT_DOCK-8888}
export VIP_NOTEBOOK_DIR_DOCK=${VIP_NOTEBOOK_DIR_DOCK-/notebooks}
export VIP_NOTEBOOK_CONFIG_DIR_DOCK=${VIP_NOTEBOOK_CONFIG_DIR_DOCK-/profile/nbconfig}
export VIP_NOTEBOOK_CUSTOM_DIR_DOCK=${VIP_NOTEBOOK_CUSTOM_DIR_DOCK-/profile/custom}
export VIP_NOTEBOOK_MPL_VOLUME=${VIP_NOTEBOOK_MPL_VOLUME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}_matplotlib}
export VIP_NOTEBOOK_MPL_DIR_DOCK=${VIP_NOTEBOOK_MPL_DIR_DOCK-/matplotlib}
# VXL
export VIP_VXL_DIR_DOCK=${VIP_VXL_DIR_DOCK-/vxl}
export VIP_VXL_SRC_DIR_DOCK=${VIP_VXL_SRC_DIR_DOCK-/vxl_src}
export VIP_VXL_PYTHON_DIR_DOCK=${VIP_VXL_PYTHON_DIR_DOCK-${VIP_VXL_DIR_DOCK}/lib/python2.7/site-packages/vxl}
export VIP_VXL_BIN_DIR_DOCK=${VIP_VXL_BIN_DIR_DOCK-${VIP_VXL_DIR_DOCK}/bin}
export VIP_VXL_SHARE_DIR_DOCK=${VIP_VXL_SHARE_DIR_DOCK-${VIP_VXL_DIR_DOCK}/share}
export VIP_VXL_VOLUME=${VIP_VXL_VOLUME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}_vxl}
# nginx
export VIP_NGINX_SSL_VOLUME=${VIP_NGINX_SSL_VOLUME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}_ssl}
# uwsgi
export VIP_UWSGI_PORT_DOCK=${VIP_UWSGI_PORT_DOCK-8000}
export VIP_UWSGI_STATS_PORT_DOCK=${VIP_UWSGI_STATS_PORT_DOCK-8001}
export VIP_UWSGI_PARAMS=${VIP_UWSGI_PARAMS-${VIP_DJANGO_SITE}/uwsgi_params}
export VIP_UWSGI_DEPLOY_ON_START=${VIP_UWSGI_DEPLOY_ON_START-1}
# Daphne
export VIP_DAPHNE_PORT_DOCK=${VIP_DAPHNE_PORT_DOCK-8080}
export VIP_DAPHNE_CHANNEL_LAYER=${VIP_DAPHNE_CHANNEL_LAYER-voxel_globe.vip.asgi:channel_layer}
# Redis
export VIP_REDIS_PORT_DOCK=${VIP_REDIS_PORT_DOCK-6379}
export VIP_REDIS_DIR_DOCK=${VIP_REDIS_DIR_DOCK-/data}
export VIP_REDIS_VOLUME=${VIP_REDIS_VOLUME-${VIP_DOCKER_CONTAINER_NAME_PREFIX}_redis}
##### Docker Switching #####
#This will copy all variables VIP_*_DOCK on top of VIP_*. This way everything
#the containers don't need to know to look for _DOCK, they just use the normal
#name
if [ "${VIP_IN_DOCKER}" == "1" ]; then #I must be in a docker
for VIP_TEMP_VAR in $(compgen -A variable | grep VIP_.*_DOCK\$); do
declare -x ${VIP_TEMP_VAR%_*}="${!VIP_TEMP_VAR}"
done
fi
##########################################################################
############################ Non-VIP settings ############################
##########################################################################
#These parameters are not protected by the VIP Prefix, and thus
#Affect many application, but hopefully in a good way :)
export VIP_PYTHONPATH=${VIP_PYTHONPATH:+${VIP_PYTHONPATH}:}${VIP_PROJECT_DIR}:${VIP_VXL_PYTHON_DIR_DOCK}:${VIP_VSI_DIR}/python
#TODO make this docker agnostic with some global docker flag that switches VIP_VXL_PYTHON_DIR
export BOXM2_OPENCL_DIR=${BOXM2_OPENCL_DIR-${VIP_VXL_SHARE_DIR_DOCK}/vxl/cl/boxm2/}
export VOLM_DIR=${VOLM_DIR-${VIP_VXL_SHARE_DIR_DOCK}/vxl}
export DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE-${VIP_DJANGO_SETTINGS_MODULE}}
#I don't know if this is actually used, but it is mentioned in the Geodjango tutorial
export POSTGIS_ENABLE_OUTDB_RASTERS=${POSTGIS_ENABLE_OUTDB_RASTERS-1}
export POSTGIS_GDAL_ENABLED_DRIVERS=${POSTGIS_GDAL_ENABLED_DRIVERS-ENABLE_ALL}
export POSTGIS_GDAL_ENABLED_DRIVERS=${POSTGIS_GDAL_ENABLED_DRIVERS-GTiff PNG JPEG GIF XYZ}
export PYTHONPATH="${VIP_PYTHONPATH}${PYTHONPATH:+:${PYTHONPATH}}"
#Source to override values USING previously defined values
if [ -e "${VIP_LOCAL_SETTINGS_POST}" ]; then
source "${VIP_LOCAL_SETTINGS_POST}"
else
echo '#Put local setting in this file
#Use this file ONLY when you need the value of other environment variables
#Other variables will not be substituted with values from this file. To get
#proper variable substitution, use VIP_LOCAL_SETTINGS' > ${VIP_LOCAL_SETTINGS_POST}
fi
unset VIP_TEMP_VAR set_temp_array