[ARVADOS-DEV] updated: 400c39aabb36fa98b8878806bd5210677495527a

git at public.curoverse.com git at public.curoverse.com
Mon Jul 6 10:26:46 EDT 2015


Summary of changes:
 .../arvados-api-server-upgrade.sh                  | 24 +++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

       via  400c39aabb36fa98b8878806bd5210677495527a (commit)
      from  287590ce79a8cf78573e1edf5bb8cd85c8e48210 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 400c39aabb36fa98b8878806bd5210677495527a
Author: Brett Smith <brett at curoverse.com>
Date:   Mon Jul 6 10:26:44 2015 -0400

    6388: Extend API server upgrade script to do initial database setup.
    
    This will let administrators duplicating a lot of logic that already
    exists in the script.

diff --git a/jenkins/arvados-api-server-extras/arvados-api-server-upgrade.sh b/jenkins/arvados-api-server-extras/arvados-api-server-upgrade.sh
index 0d125cf..ace07c7 100755
--- a/jenkins/arvados-api-server-extras/arvados-api-server-upgrade.sh
+++ b/jenkins/arvados-api-server-extras/arvados-api-server-upgrade.sh
@@ -48,13 +48,16 @@ if [[ ! -e $RELEASE_PATH/tmp ]]; then mkdir -p $RELEASE_PATH/tmp; fi
 if [[ ! -e $RELEASE_PATH/log ]]; then ln -s $SHARED_PATH/log $RELEASE_PATH/log; fi
 if [[ ! -e $SHARED_PATH/log/production.log ]]; then touch $SHARED_PATH/log/production.log; fi
 
+cd "$RELEASE_PATH"
+export RAILS_ENV=production
+
 echo "Running bundle install"
-(cd $RELEASE_PATH && RAILS_ENV=production bundle install --path $SHARED_PATH/vendor_bundle)
+bundle install --path $SHARED_PATH/vendor_bundle
 echo "Done."
 
 echo "Precompiling assets"
 # precompile assets; thankfully this does not take long
-(cd $RELEASE_PATH; RAILS_ENV=production bundle exec rake assets:precompile)
+bundle exec rake assets:precompile
 echo "Done."
 
 echo "Ensuring directory and file permissions"
@@ -70,7 +73,7 @@ chmod 644 $SHARED_PATH/log/*
 echo "Done."
 
 echo "Running sanity check"
-(cd $RELEASE_PATH && RAILS_ENV=production bundle exec rake config:check)
+bundle exec rake config:check
 SANITY_CHECK_EXIT_CODE=$?
 echo "Done."
 
@@ -80,8 +83,19 @@ if [[ "$SANITY_CHECK_EXIT_CODE" != "0" ]]; then
   exit $SANITY_CHECK_EXIT_CODE
 fi
 
-echo "Starting db:migrate"
-(cd $RELEASE_PATH && bundle exec rake RAILS_ENV=production  db:migrate)
+echo "Checking database status"
+# If we use `grep -q`, rake will write a backtrace on EPIPE.
+if bundle exec rake db:migrate:status | grep '^database: ' >/dev/null; then
+    echo "Starting db:migrate"
+    bundle exec rake db:migrate
+elif [ 0 -eq ${PIPESTATUS[0]} ]; then
+    # The database exists, but the migrations table doesn't.
+    echo "Setting up database"
+    bundle exec rake db:structure:load db:seed
+else
+    echo "Error: Database is not ready to set up. Aborting." >&2
+    exit 1
+fi
 echo "Done."
 
 echo "Restarting nginx"

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list