@@ -16,7 +16,7 @@ cleanup () {
16
16
return 0;
17
17
fi
18
18
echo " Cleaning up..."
19
- docker-compose down & > /dev/null
19
+ docker-compose stop & > /dev/null
20
20
DID_CLEAN_UP=1
21
21
}
22
22
trap cleanup ERR INT TERM
@@ -55,30 +55,8 @@ if [ "$RAM_AVAILABLE_IN_DOCKER" -lt "$MIN_RAM" ]; then
55
55
exit -1
56
56
fi
57
57
58
- # Very naively check whether there's an existing sentry-postgres volume and the PG version in it
59
- if [[ $( docker volume ls -q --filter name=sentry-postgres) && $( docker run --rm -v sentry-postgres:/db busybox cat /db/PG_VERSION 2> /dev/null) == " 9.5" ]]; then
60
- # If this is Postgres 9.5 data, start upgrading it to 9.6 in a new volume
61
- docker run --rm \
62
- -v sentry-postgres:/var/lib/postgresql/9.5/data \
63
- -v sentry-postgres-new:/var/lib/postgresql/9.6/data \
64
- tianon/postgres-upgrade:9.5-to-9.6
65
-
66
- # Get rid of the old volume as we'll rename the new one to that
67
- docker volume rm sentry-postgres
68
- docker volume create --name sentry-postgres
69
- # There's no rename volume in Docker so copy the contents from old to new name
70
- # Also append the `host all all all trust` line as `tianon/postgres-upgrade:9.5-to-9.6`
71
- # doesn't do that automatically.
72
- docker run --rm -v sentry-postgres-new:/from -v sentry-postgres:/to alpine ash -c \
73
- " cd /from ; cp -av . /to ; echo 'host all all all trust' >> /to/pg_hba.conf"
74
- # Finally, remove the new old volume as we are all in sentry-postgres now
75
- docker volume rm sentry-postgres-new
76
- fi
77
-
78
- echo " "
79
- ensure_file_from_example $SENTRY_CONFIG_PY
80
- ensure_file_from_example $SENTRY_CONFIG_YML
81
- ensure_file_from_example $SENTRY_EXTRA_REQUIREMENTS
58
+ # Ensure nothing is working while we install/update
59
+ docker-compose stop
82
60
83
61
echo " "
84
62
echo " Creating volumes for persistent storage..."
@@ -90,6 +68,11 @@ echo "Created $(docker volume create --name=sentry-kafka)."
90
68
echo " Created $( docker volume create --name=sentry-clickhouse) ."
91
69
echo " Created $( docker volume create --name=sentry-symbolicator) ."
92
70
71
+ echo " "
72
+ ensure_file_from_example $SENTRY_CONFIG_PY
73
+ ensure_file_from_example $SENTRY_CONFIG_YML
74
+ ensure_file_from_example $SENTRY_EXTRA_REQUIREMENTS
75
+
93
76
echo " "
94
77
echo " Generating secret key..."
95
78
# This is to escape the secret key to be used in sed below
@@ -106,6 +89,26 @@ docker-compose build --force-rm
106
89
echo " "
107
90
echo " Docker images built."
108
91
92
+ # Very naively check whether there's an existing sentry-postgres volume and the PG version in it
93
+ if [[ $( docker volume ls -q --filter name=sentry-postgres) && $( docker run --rm -v sentry-postgres:/db busybox cat /db/PG_VERSION 2> /dev/null) == " 9.5" ]]; then
94
+ # If this is Postgres 9.5 data, start upgrading it to 9.6 in a new volume
95
+ docker run --rm \
96
+ -v sentry-postgres:/var/lib/postgresql/9.5/data \
97
+ -v sentry-postgres-new:/var/lib/postgresql/9.6/data \
98
+ tianon/postgres-upgrade:9.5-to-9.6
99
+
100
+ # Get rid of the old volume as we'll rename the new one to that
101
+ docker volume rm sentry-postgres
102
+ docker volume create --name sentry-postgres
103
+ # There's no rename volume in Docker so copy the contents from old to new name
104
+ # Also append the `host all all all trust` line as `tianon/postgres-upgrade:9.5-to-9.6`
105
+ # doesn't do that automatically.
106
+ docker run --rm -v sentry-postgres-new:/from -v sentry-postgres:/to alpine ash -c \
107
+ " cd /from ; cp -av . /to ; echo 'host all all all trust' >> /to/pg_hba.conf"
108
+ # Finally, remove the new old volume as we are all in sentry-postgres now
109
+ docker volume rm sentry-postgres-new
110
+ fi
111
+
109
112
echo " "
110
113
echo " Setting up database..."
111
114
if [ $CI ]; then
@@ -120,6 +123,13 @@ else
120
123
docker-compose run --rm web upgrade
121
124
fi
122
125
126
+ SENTRY_DATA_NEEDS_MIGRATION=$( docker run --rm -v sentry-data:/data alpine ash -c " [ ! -d '/data/files' ] && ls -A1x /data | wc -l" )
127
+ if [ " $SENTRY_DATA_NEEDS_MIGRATION " ]; then
128
+ echo " Migrating file storage..."
129
+ docker run --rm -v sentry-data:/data alpine ash -c \
130
+ " mkdir -p /tmp/files; mv /data/* /tmp/files/; mv /tmp/files /data/files"
131
+ fi
132
+
123
133
echo " Boostrapping Snuba..."
124
134
docker-compose up -d kafka redis clickhouse
125
135
until $( docker-compose run --rm clickhouse clickhouse-client -h clickhouse --query=" SHOW TABLES;" | grep -q sentry_local) ; do
@@ -130,12 +140,12 @@ until $(docker-compose run --rm clickhouse clickhouse-client -h clickhouse --que
130
140
done ;
131
141
echo " "
132
142
133
- SENTRY_DATA_NEEDS_MIGRATION= $( docker run --rm -v sentry-data:/data alpine ash -c " [ ! -d '/data/files' ] && ls -A1x /data | wc -l " )
134
- if [ " $SENTRY_DATA_NEEDS_MIGRATION " ] ; then
135
- echo " Migrating file storage... "
136
- docker run --rm -v sentry-data:/data alpine ash -c \
137
- " mkdir -p /tmp/files; mv /data/* /tmp/files/; mv /tmp/files /data/files "
138
- fi
143
+ set -o allexport
144
+ source .env
145
+ set +o allexport
146
+ echo " Migrating old events for the last $SENTRY_EVENT_RETENTION_DAYS days... "
147
+ docker-compose run --rm web django backfill_eventstream --no-input --last-days $SENTRY_EVENT_RETENTION_DAYS
148
+ echo " "
139
149
140
150
cleanup
141
151
0 commit comments