-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·86 lines (71 loc) · 3.75 KB
/
run.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
#!/bin/bash -e
# WARNING: You have to adapt the script for your installation. It contains hard-coded values for another installation.
# An example script to run the app in production. It uses data volumes under the $DATA_ROOT directory.
# By default /srv. It uses a MongoDB database, tozd/meteor-mongodb image which is automatically run as well.
NAME='council'
DATA_ROOT='/srv'
MONGODB_DATA="${DATA_ROOT}/${NAME}/mongodb/data"
MONGODB_LOG="${DATA_ROOT}/${NAME}/mongodb/log"
METEOR_LOG="${DATA_ROOT}/${NAME}/meteor/log"
METEOR_STORAGE="${DATA_ROOT}/${NAME}/meteor/storage"
export PEERDB_INSTANCES=2
export WORKER_INSTANCES=2
# This file is used by both peermind/peermind and tozd/meteor-mongodb images. The latter automatically creates the
# database and accounts with provided passwords. The file should look like:
#
# MONGODB_ADMIN_PWD='<pass>'
# MONGODB_CREATE_PWD='<pass>'
# MONGODB_OPLOGGER_PWD='<pass>'
#
# export MONGO_URL="mongodb://meteor:${MONGODB_CREATE_PWD}@council_mongodb/meteor"
# export MONGO_OPLOG_URL="mongodb://oplogger:${MONGODB_OPLOGGER_PWD}@council_mongodb/local?authSource=admin"
CONFIG="${DATA_ROOT}/${NAME}/run.config"
mkdir -p "$MONGODB_DATA"
mkdir -p "$MONGODB_LOG"
mkdir -p "$METEOR_LOG"
mkdir -p "$METEOR_STORAGE"
touch "$CONFIG"
if [ ! -s "$CONFIG" ]; then
echo "Set MONGODB_CREATE_PWD, MONGODB_ADMIN_PWD, MONGODB_OPLOGGER_PWD and export MONGO_URL, MONGO_OPLOG_URL environment variables in '$CONFIG'."
exit 1
fi
docker stop "${NAME}_mongodb" || true
sleep 1
docker rm "${NAME}_mongodb" || true
sleep 1
docker run --detach=true --restart=always --name "${NAME}_mongodb" --volume "${CONFIG}:/etc/service/mongod/run.config" \
--volume "${MONGODB_LOG}:/var/log/mongod" --volume "${MONGODB_DATA}:/var/lib/mongodb" \
tozd/meteor-mongodb:2.6
for I in $(seq 1 $PEERDB_INSTANCES); do
mkdir -p "${DATA_ROOT}/${NAME}/peerdb$I/log"
docker stop "${NAME}_peerdb$I" || true
sleep 1
docker rm "${NAME}_peerdb$I" || true
sleep 1
docker run --detach=true --restart=always --name "${NAME}_peerdb$I" --env WORKER_INSTANCES=0 --env PEERDB_MIGRATIONS_DISABLED=1 \
--env PEERDB_INSTANCES --env PEERDB_INSTANCE="$((I-1))" --env ROOT_URL=https://council.cloyne.org --env MAIL_URL=smtp://mail.tnode.com \
--env STORAGE_DIRECTORY=/storage --volume "${CONFIG}:/etc/service/meteor/run.config" --volume "${DATA_ROOT}/${NAME}/peerdb$I/log:/var/log/meteor" \
--volume "${METEOR_STORAGE}:/storage" --link "${NAME}_mongodb:mongodb" \
peermind/peermind
done
for I in $(seq 1 $WORKER_INSTANCES); do
mkdir -p "${DATA_ROOT}/${NAME}/worker$I/log"
docker stop "${NAME}_worker$I" || true
sleep 1
docker rm "${NAME}_worker$I" || true
sleep 1
docker run --detach=true --restart=always --name "${NAME}_worker$I" --env WORKER_INSTANCES --env PEERDB_MIGRATIONS_DISABLED=1 \
--env PEERDB_INSTANCES=0 --env ROOT_URL=https://council.cloyne.org --env MAIL_URL=smtp://mail.tnode.com \
--env STORAGE_DIRECTORY=/storage --volume "${CONFIG}:/etc/service/meteor/run.config" --volume "${DATA_ROOT}/${NAME}/worker$I/log:/var/log/meteor" \
--volume "${METEOR_STORAGE}:/storage" --link "${NAME}_mongodb:mongodb" \
peermind/peermind
done
docker stop "${NAME}_web" || true
sleep 1
docker rm "${NAME}_web" || true
sleep 1
docker run --detach=true --restart=always --name "${NAME}_web" --env WORKER_INSTANCES=0 --env PEERDB_INSTANCES=0 \
--env VIRTUAL_HOST=council.cloyne.org --env VIRTUAL_URL=/ --env VIRTUAL_LETSENCRYPT=true --env ROOT_URL=https://council.cloyne.org \
--env MAIL_URL=smtp://mail.tnode.com --env STORAGE_DIRECTORY=/storage --env METEOR_STORAGE_CHOWN=1 --volume "${CONFIG}:/etc/service/meteor/run.config" \
--volume "${METEOR_LOG}:/var/log/meteor" --volume "${METEOR_STORAGE}:/storage" --link "${NAME}_mongodb:mongodb" \
peermind/peermind