diff --git a/.gitignore b/.gitignore index 34977ee7..fc482c42 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -.idea \ No newline at end of file +config/environments/*.js +.idea diff --git a/Makefile b/Makefile index 92a282c7..8048c6c1 100644 --- a/Makefile +++ b/Makefile @@ -4,5 +4,8 @@ all: clean: rm -rf node_modules/* -check: +config/environments/test.js: config/environments/test.js.example + ./configure + +check: config/environments/test.js ./run_tests.sh diff --git a/README.md b/README.md index 80254eaa..3fc93d6e 100644 --- a/README.md +++ b/README.md @@ -31,19 +31,22 @@ modules. At any time just wipe out the node_modules/ directory and run Configure --------- -Edit config/environments/.js files +Create a config/environments/.js file (there are .example files +to start from). -Look at lib/cartodb/server_options for more on config +Look at lib/cartodb/server_options.js for more on config Run --- ``` -node app.js [development | staging | production] +node app.js ``` -Note that caches are kept in redis. If you're not seeing what -you expect there may be out-of-sync records in there. +Where is the name of a configuration file under config/environments/. + +Note that caches are kept in redis. If you're not seeing what you expect +there may be out-of-sync records in there. Take a look: http://redis.io/commands diff --git a/config/environments/development.js b/config/environments/development.js.example similarity index 100% rename from config/environments/development.js rename to config/environments/development.js.example diff --git a/config/environments/production.js b/config/environments/production.js.example similarity index 100% rename from config/environments/production.js rename to config/environments/production.js.example diff --git a/config/environments/staging.js b/config/environments/staging.js.example similarity index 100% rename from config/environments/staging.js rename to config/environments/staging.js.example diff --git a/config/environments/test.js b/config/environments/test.js.example similarity index 100% rename from config/environments/test.js rename to config/environments/test.js.example diff --git a/configure b/configure new file mode 100755 index 00000000..07d221b3 --- /dev/null +++ b/configure @@ -0,0 +1,38 @@ +#!/bin/sh + +usage() { + echo "Usage: $0 [OPTION]" + echo + echo "Configuration:" + echo " --help display this help and exit" + echo " --with-pgport=NUM access PostgreSQL server on TCP port NUM" +} + +PGPORT=5432 + +while test -n "$1"; do + case "$1" in + --help|-h) + usage + exit 0 + ;; + --with-pgport=*) + PGPORT=`echo "$1" | cut -d= -f2` + ;; + *) + echo "Unknown option '$1'" >&2 + usage >&2 + exit 1 + esac + shift +done + +echo "PGPORT: $PGPORT" + +# TODO: allow specifying configuration settings ! +for f in config/environments/*.example; do + o=`dirname "$f"`/`basename "$f" .example` + echo "Writing $o" + # 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" > "$o" +done