Remember per-environment ./configure parameters

This is to avoid breaking test.js configuration while switching
between branches.
This commit is contained in:
Sandro Santilli 2013-11-14 16:21:40 +01:00
parent 4c95af2c69
commit ed23d10364
3 changed files with 31 additions and 10 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
node_modules* node_modules*
config.status*
config/environments/*.js config/environments/*.js
.idea .idea
tools/munin/windshaft.conf tools/munin/windshaft.conf

View File

@ -6,9 +6,15 @@ all:
clean: clean:
rm -rf node_modules/* rm -rf node_modules/*
config/environments/test.js: config/environments/test.js.example Makefile distclean: clean
rm config.status*
config.status--test:
./configure --environment=test ./configure --environment=test
config/environments/test.js: config.status--test
./config.status--test
check-local: config/environments/test.js check-local: config/environments/test.js
./run_tests.sh ${RUNTESTFLAGS} \ ./run_tests.sh ${RUNTESTFLAGS} \
test/unit/cartodb/redis_pool.test.js \ test/unit/cartodb/redis_pool.test.js \

28
configure vendored
View File

@ -17,11 +17,15 @@
# --strk(2012-07-23) # --strk(2012-07-23)
# #
PGPORT=5432 ENVDIR=config/environments
SQLAPI_PORT=8080
PGPORT=
SQLAPI_PORT=
MAPNIK_VERSION= MAPNIK_VERSION=
ENVIRONMENT=development ENVIRONMENT=development
STATUS="$0 $*"
usage() { usage() {
echo "Usage: $0 [OPTION]" echo "Usage: $0 [OPTION]"
echo echo
@ -59,20 +63,30 @@ while test -n "$1"; do
shift shift
done done
ENVEX=./${ENVDIR}/${ENVIRONMENT}.js.example
if [ -z "$PGPORT" ]; then
PGPORT=`node -e "console.log(require('${ENVEX}').postgres.port)"`
fi
if [ -z "$SQLAPI_PORT" ]; then
SQLAPI_PORT=`node -e "console.log(require('${ENVEX}').sqlapi.port)"`
fi
echo "PGPORT: $PGPORT" echo "PGPORT: $PGPORT"
echo "SQLAPI_PORT: $SQLAPI_PORT" echo "SQLAPI_PORT: $SQLAPI_PORT"
echo "MAPNIK_VERSION: $MAPNIK_VERSION" echo "MAPNIK_VERSION: $MAPNIK_VERSION"
echo "ENVIRONMENT: $ENVIRONMENT" echo "ENVIRONMENT: $ENVIRONMENT"
# TODO: allow specifying configuration settings ! o=`dirname "${ENVEX}"`/`basename "${ENVEX}" .example`
for f in config/environments/${ENVIRONMENT}.js.example; do
o=`dirname "$f"`/`basename "$f" .example`
echo "Writing $o" echo "Writing $o"
# See http://austinmatzko.com/2008/04/26/sed-multi-line-search-and-replace/ # See http://austinmatzko.com/2008/04/26/sed-multi-line-search-and-replace/
sed -n "1h;1!H;\${;g;s/\(,postgres: {[^}]*port: *'\?\)[^',]*\('\?,\)/\1$PGPORT\2/;p;}" < "$f" \ sed -n "1h;1!H;\${;g;s/\(,postgres: {[^}]*port: *'\?\)[^',]*\('\?,\)/\1$PGPORT\2/;p;}" < "${ENVEX}" \
| sed "s/mapnik_version:.*/mapnik_version: '$MAPNIK_VERSION'/" \ | sed "s/mapnik_version:.*/mapnik_version: '$MAPNIK_VERSION'/" \
| sed -n "1h;1!H;\${;g;s/\(,sqlapi: {[^}]*port: *'\?\)[^',]*\('\?,\)/\1$SQLAPI_PORT\2/;p;}" \ | sed -n "1h;1!H;\${;g;s/\(,sqlapi: {[^}]*port: *'\?\)[^',]*\('\?,\)/\1$SQLAPI_PORT\2/;p;}" \
> "$o" > "$o"
done STATUSFILE=config.status--${ENVIRONMENT}
echo "Writing ${STATUSFILE}"
echo ${STATUS} > ${STATUSFILE} && chmod +x ${STATUSFILE}