diff --git a/README.md b/README.md index bbe005c..ed3b99d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ See the [Wiki](https://github.com/sul-dlss/robot-master/wiki) for general docume - config - certs : authentication certificates for workflow service - deploy : host-level Capistrano configuration - - environments : configuration for dev,test,prod environments + - environments : configuration for dev,stage,prod environments - workflows : workflow specific configuration - steps, dependencies. One directory per workflow. - lib : ruby classes needed for your local robots - sdrIngest : all of the robots for a particular workflow. One directory per workflow @@ -70,9 +70,9 @@ See `bin/cron_jobs.txt` or `ssh` onto a deploy system and run `crontab -e`. ``` ```ruby # modify the defaults, e.g. - #ENV['SDR_HOST'] ||= 'sdr-staging1' + #ENV['SDR_HOST'] ||= 'sdr-stage1' #ENV['SDR_USER'] ||= 'sdr_user' - #ENV['ROBOT_ENVIRONMENT'] = 'staging' + #ENV['ROBOT_ENVIRONMENT'] = 'stage' # Note that the value of ROBOT_ENVIRONMENT entails the existence of two config files: # config/environments/${ROBOT_ENVIRONMENT}.rb # config/environments/robots_${ROBOT_ENVIRONMENT}.yml diff --git a/bin/environment.rb b/bin/environment.rb index f52a2d7..3deb16a 100755 --- a/bin/environment.rb +++ b/bin/environment.rb @@ -16,11 +16,11 @@ # Make sure a value is set for ROBOT_ENVIRONMENT ENV['ROBOT_ENVIRONMENT'] = ( case `hostname -s`.chomp - when "sdr-services", "sul-sdr-services" + when 'sul-sdr-services' 'production' - when "sdr-services-test" - 'staging' - when "sul-sdr-services-dev" + when 'sdr-services-test', 'sdr-services-test2' + 'stage' + when 'sul-sdr-services-dev' 'integration' else 'development' diff --git a/bin/sdr-preservation-core_ctl.sh b/bin/sdr-preservation-core_ctl.sh new file mode 100755 index 0000000..6083ccf --- /dev/null +++ b/bin/sdr-preservation-core_ctl.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +if [ -d ~/sdr-preservation-core/current ]; then + cd ~/sdr-preservation-core/current +else + echo "ERROR: There is no application installation in ~/sdr-preservation-core/current" + exit 1 +fi + + +# ---- +# The ROBOT_ENVIRONMENT values here should match the config/environment/* files in the shared configs at +# https://github.com/sul-dlss/shared_configs/tree/sdr-preservation-core_{stage} where +# {stage} is a capistrano stage, like 'dev|stage|prod'. + +HOSTNAME=$(hostname -s) +case "$HOSTNAME" in + 'sul-sdr-services') + export ROBOT_ENVIRONMENT='production' + ;; + + 'sdr-services-test' | 'sdr-services-test2') + export ROBOT_ENVIRONMENT='stage' + ;; + + 'sul-sdr-services-dev') + export ROBOT_ENVIRONMENT='integration' + ;; + + *) + echo "WARNING: defaulting to localhost 'development'" + export ROBOT_ENVIRONMENT='development' + ;; +esac + +echo "Using ROBOT_ENVIRONMENT=$ROBOT_ENVIRONMENT" + + +# ---- +# Robot control commands: + +case "$1" in + start) + bundle exec controller boot + ;; + + stop) + bundle exec controller stop + bundle exec controller quit + ;; + + status) + bundle exec controller status + ;; + + restart) + bundle exec controller stop + bundle exec controller quit + bundle exec controller boot + ;; + + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 +esac + diff --git a/bin/sdr-preservation-core_restart.sh b/bin/sdr-preservation-core_restart.sh deleted file mode 100755 index 709ad10..0000000 --- a/bin/sdr-preservation-core_restart.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# The ROBOT_ENVIRONMENT values here should match the -# environment files in the shared configs at -# https://github.com/sul-dlss/sdr-configs/tree/master/sdr-preservation-core/config/environments - -if hostname | egrep -q '\-dev'; then - export ROBOT_ENVIRONMENT='integration' -fi -if hostname | egrep -q '\-test|\-stage'; then - export ROBOT_ENVIRONMENT='test' -fi -if hostname | egrep -q '\-prod'; then - export ROBOT_ENVIRONMENT='production' -fi - -echo "Using ROBOT_ENVIRONMENT=$ROBOT_ENVIRONMENT" -cd ~/sdr-preservation-core/current -bundle exec controller stop -bundle exec controller quit -bundle exec controller boot diff --git a/bin/sdr-preservation-core_status.sh b/bin/sdr-preservation-core_status.sh deleted file mode 100755 index d77c9d7..0000000 --- a/bin/sdr-preservation-core_status.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# The ROBOT_ENVIRONMENT values here should match the -# environment files in the shared configs at -# https://github.com/sul-dlss/sdr-configs/tree/master/sdr-preservation-core/config/environments - -if hostname | egrep -q '\-dev'; then - export ROBOT_ENVIRONMENT='integration' -fi -if hostname | egrep -q '\-test|\-stage'; then - export ROBOT_ENVIRONMENT='test' -fi -if hostname | egrep -q '\-prod'; then - export ROBOT_ENVIRONMENT='production' -fi - -echo "Using ROBOT_ENVIRONMENT=$ROBOT_ENVIRONMENT" -cd ~/sdr-preservation-core/current -bundle exec controller status diff --git a/bin/sdr-preservation-core_stop.sh b/bin/sdr-preservation-core_stop.sh deleted file mode 100755 index 715dc46..0000000 --- a/bin/sdr-preservation-core_stop.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# The ROBOT_ENVIRONMENT values here should match the -# environment files in the shared configs at -# https://github.com/sul-dlss/sdr-configs/tree/master/sdr-preservation-core/config/environments - -if hostname | egrep -q '\-dev'; then - export ROBOT_ENVIRONMENT='integration' -fi -if hostname | egrep -q '\-test|\-stage'; then - export ROBOT_ENVIRONMENT='test' -fi -if hostname | egrep -q '\-prod'; then - export ROBOT_ENVIRONMENT='production' -fi - -echo "Using ROBOT_ENVIRONMENT=$ROBOT_ENVIRONMENT" -cd ~/sdr-preservation-core/current -bundle exec controller stop -bundle exec controller quit diff --git a/config/deploy/stage.rb b/config/deploy/stage.rb index 843b13c..fbf9ef4 100644 --- a/config/deploy/stage.rb +++ b/config/deploy/stage.rb @@ -4,7 +4,7 @@ # ROBOT_ENVIRONMENT implies remote :deploy_to contains # config/environments/#{ROBOT_ENVIRONMENT}.rb # config/environments/robots_#{ROBOT_ENVIRONMENT}.rb - 'ROBOT_ENVIRONMENT' => 'test' + 'ROBOT_ENVIRONMENT' => 'stage' } server 'sdr-services-test.stanford.edu', user: 'sdr2service', roles: %w{app}