diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-02-06 15:44:06 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-02-06 15:44:06 +0000 |
commit | 3dbdc946530f468a2f2a7e86108f437fc6bcff9f (patch) | |
tree | f74969c83842e8258317ce676512aba237b4efea | |
parent | 3fff90e4003ec003a5a49fd2e155c2cc220485c9 (diff) |
Create config/rails_env.rb in production
Partially revert 2eac4bef8d73f47bbe579b6f787ef54b8d782d7a, creating
config/rails_env.rb in production only. This should address some of
the difficulties with config/rails_env.rb causing unexpected behaviour
in development, whilst forcing Rails into production environment
where necessary for scripts run from cron etc.
Closes #418?
-rw-r--r-- | config/general.yml-example | 5 | ||||
-rwxr-xr-x | script/rails-post-deploy | 54 |
2 files changed, 41 insertions, 18 deletions
diff --git a/config/general.yml-example b/config/general.yml-example index 98f04d0bf..ed04e0fd5 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -92,7 +92,10 @@ COOKIE_STORE_SESSION_SECRET: 'your secret key here, make it long and random' # checks in a few obvious places. READ_ONLY: '' -# Doesn't do anything right now. +# Is this a staging or dev site (1) or a live site (0). +# Controls whether or not the rails-post-deploy script +# will create the file config/rails_env.rb file to force +# Rails into production environment. STAGING_SITE: 1 # Recaptcha, for detecting humans. Get keys here: http://recaptcha.net/whyrecaptcha.html diff --git a/script/rails-post-deploy b/script/rails-post-deploy index 263d5d926..8b9476afe 100755 --- a/script/rails-post-deploy +++ b/script/rails-post-deploy @@ -22,42 +22,62 @@ cd app/.. # read config file in for later (STAGING_SITE) if [ -e "config/general" ] || [ -e "config/general.yml" ] then - . commonlib/shlib/deployfns - read_conf config/general + . commonlib/shlib/deployfns + read_conf config/general else - OPTION_DOMAIN=127.0.0.1:3000 - OPTION_STAGING_SITE=1 + OPTION_DOMAIN=127.0.0.1:3000 + OPTION_STAGING_SITE=1 fi # create initial log files if [ -e $APP_DIR/../logs ] then - # mySociety servers have logs dir in level above - rm -f log - ln -s $APP_DIR/../logs log + # mySociety servers have logs dir in level above + rm -f log + ln -s $APP_DIR/../logs log else - # otherwise just make the directory - if [ -h log ] - then - # remove any old-style symlink first - rm -f log - fi - mkdir -p log + # otherwise just make the directory + if [ -h log ] + then + # remove any old-style symlink first + rm -f log + fi + mkdir -p log fi # link the "downloads" directory in the cache to somewhere it can be served if [ ! -e $APP_DIR/public/download ] then - mkdir -p $APP_DIR/cache/zips/download - ln -s $APP_DIR/cache/zips/download $APP_DIR/public/ + mkdir -p $APP_DIR/cache/zips/download + ln -s $APP_DIR/cache/zips/download $APP_DIR/public/ fi cd log touch development.log fastcgi.crash.log production.log test.log cd .. +# Force appropriate environment in production +if [ "$OPTION_STAGING_SITE" = "0" ] +then + if [ ! -e "config/rails_env.rb" ] + then + cat <<-END + + ***************************************************************** + WARNING: About to make config/rails_env.rb which, via special + code in config/boot.rb, forces the Rails environment to be + "production". If this is a development system, please edit your + config/general.yml file and set the STAGING_SITE option to 1, + and also delete the generated config/rails_env.rb file. + ***************************************************************** + + END + fi + echo "ENV['RAILS_ENV'] = 'production'" > config/rails_env.rb +fi + if [ -n "$OPTION_THEME_URL" ] then - script/plugin install --force $OPTION_THEME_URL + script/plugin install --force $OPTION_THEME_URL fi # upgrade database |