diff options
| author | Robert | 2017-07-06 15:56:56 +0200 | 
|---|---|---|
| committer | Robert | 2017-07-06 15:56:56 +0200 | 
| commit | 29bd718088d4fbcdda7da3cc4d1afdfe527b76be (patch) | |
| tree | 28af2a85ca2859e46eb84ca883e38bbbb1cfc250 | |
| parent | 9d540268facd37a8326e392a644c2058e0f0d34b (diff) | |
| parent | 6509f34e8ebdac1c0d685a9f8acaa31d2c99c293 (diff) | |
| download | chouette-core-29bd718088d4fbcdda7da3cc4d1afdfe527b76be.tar.bz2 | |
Merge branch 'master' of github.com:af83/stif-boiv
| -rw-r--r-- | config/environments/production.rb | 18 | ||||
| -rwxr-xr-x | install/deploy-helper.sh | 22 | ||||
| -rwxr-xr-x | install/stif-boiv-setup.sh | 33 | ||||
| -rw-r--r-- | lib/tasks/install.rake | 4 | 
4 files changed, 72 insertions, 5 deletions
| diff --git a/config/environments/production.rb b/config/environments/production.rb index 41b31b1e8..19fc23024 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -111,6 +111,16 @@ Rails.application.configure do    # config.company_contact = "http://www.cityway.fr/contact/?rub_code=14"    # config.accept_user_creation = false +  config.chouette_authentication_settings = { +    type: "cas", +    cas_server: "https://portail-server/sessions", +    cas_validate_url: "http://portail-server/sessions/proxyValidate" +  } +  config.stif_portail_api = { +    key: "api_token_for_portail_goes_here", +    url: "http://portail-server" +  } +    # file to data for demo    # config.demo_data = "/path/to/demo.zip" @@ -124,6 +134,14 @@ Rails.application.configure do    config.i18n.available_locales = [:fr, :en] +  # REFLEX api url +  config.reflex_api_url = "https://pprod.reflex.stif.info/ws/reflex/V1/service=getData" +  # CODIFLIGNE api url +  config.codifligne_api_url = "https://pprod.codifligne.stif.info/rest/v1/lc/getlist" + +  # IEV +  config.iev_url = "http://worker-server:8080" +    # Set node env for browserify-rails    config.browserify_rails.node_env = "production"  end diff --git a/install/deploy-helper.sh b/install/deploy-helper.sh index 487c4539c..5fa8efb9e 100755 --- a/install/deploy-helper.sh +++ b/install/deploy-helper.sh @@ -16,6 +16,8 @@ function setup() {      mkdir -p $BASEDIR/shared/config/environments +    mkdir -p $BASEDIR/shared/config/initializers +      mkdir -p $BASEDIR/shared/public      mkdir -p $BASEDIR/shared/public/uploads      mkdir -p $BASEDIR/shared/public/assets @@ -54,6 +56,24 @@ production:    password: $DATABASE_PASSWORD  EOF      fi + + +    if [ ! -f initializers/sidekiq.rb ]; then +        cat > initializers/sidekiq.rb <<EOF +Sidekiq.configure_server do |config| +  pendings = [ +    LineReferential.find_by(name: 'CodifLigne').line_referential_syncs.pending.take, +    StopAreaReferential.find_by(name: 'Reflex').stop_area_referential_syncs.pending.take +  ] +  pendings.compact.map{|sync| sync.failed({error: 'Failed by Sidekiq reboot', processing_time: 0})} +  config.redis = { url: '$SIDEKIQ_REDIS_URL' } +end + +Sidekiq.configure_client do |config| +  config.redis = { url: '$SIDEKIQ_REDIS_URL' } +end +EOF +    fi  }  function install() { @@ -85,7 +105,7 @@ function install() {          ln -s $local_directory $release_directory      done -    for file in secrets.yml database.yml environments/production.rb; do +    for file in secrets.yml database.yml environments/production.rb initializers/sidekiq.rb; do          local_file=$BASEDIR/shared/config/$file          release_file=config/$file diff --git a/install/stif-boiv-setup.sh b/install/stif-boiv-setup.sh index a2b8bd4a6..25b1882e5 100755 --- a/install/stif-boiv-setup.sh +++ b/install/stif-boiv-setup.sh @@ -1,7 +1,25 @@  #!/bin/bash -e -DATABASE_HOST=${DATABASE_HOST:-"localhost"} +export DATABASE_HOST=${DATABASE_HOST:-"localhost"} +export SIDEKIQ_REDIS_URL=${SIDEKIQ_REDIS_URL:-"redis://localhost:6379/0"} +if [[ "$#" != "1" ]] ; then +  echo "Argument count mismatch. 1 and only 1 argument expected" +  exit -1 +fi +  +SVRTYPE="$1" + +if test "$SVRTYPE" == "front"; then +  echo "*** FRONT SERVER SELECTED" +elif [[ "$SVRTYPE" == "worker" ]] ; then +  echo "*** WORKER SERVER SELECTED" +else +  echo "server type must be front or worker" +  exit -2 +fi + +exit 0  # mandatory packages and distribution upgrade  apt-get update && apt-get dist-upgrade  apt-get install -y wget sudo @@ -19,6 +37,7 @@ apt-get install -y libsqlite3-dev libproj-dev libpq-dev  gem2.3 install bundler  # Apache / Passenger +if test "$SVRTYPE" == "front"; then  echo "==== Installation de Apache 2.4 et Passenger"  apt-get install -y apache2 libapache2-mod-passenger @@ -26,19 +45,23 @@ cp stif-boiv.conf /etc/apache2/sites-available/  a2enmod expires  a2ensite stif-boiv +fi  # Redis +if test "$SVRTYPE" == "front"; then  echo "==== Installation de Redis"  apt-get install -y redis-server +fi  # Sidekiq +if test "$SVRTYPE" == "worker"; then  echo "==== Installation de Sidekiq comme service"  cp sidekiq-stif-boiv.service /etc/systemd/system/  systemctl enable sidekiq-stif-boiv - +fi  echo "==== Installation de PostgreSQL"  if [ "x$DATABASE_HOST" = "xlocalhost" ]; then @@ -58,6 +81,7 @@ fi  # NodeJS +if test "$SVRTYPE" == "front"; then  echo "==== Installation de NodeJS 5.x"  apt-get install -y apt-transport-https @@ -69,7 +93,7 @@ wget -q -O - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add  apt-get update  apt-get install -y nodejs - +fi  # Configuration de l'applicatif  echo "==== Paramétrage de l'applicatif" @@ -78,7 +102,8 @@ read -s DATABASE_PASSWORD  export DATABASE_PASSWORD -PGPASSWORD=$DATABASE_PASSWORD PGHOST=$DATABASE_HOST PGUSER=stif_boiv psql -q -c 'select 1' stif_boiv >/dev/null 2>&1 && echo "Mot de passe correct"  +PGPASSWORD=$DATABASE_PASSWORD PGHOST=$DATABASE_HOST PGUSER=stif_boiv psql -q -c 'select 1' stif_boiv >/dev/null 2>&1 && echo "Mot de passe PG correct"  +  ./deploy-helper.sh setup  echo "!!! Configuration intiale terminée. Vous pouvez maintenant déployer l'applicatif" diff --git a/lib/tasks/install.rake b/lib/tasks/install.rake index f32f3f240..5e41fa2af 100644 --- a/lib/tasks/install.rake +++ b/lib/tasks/install.rake @@ -7,12 +7,16 @@ task :package do    sh "git archive --format=tar --output=tmp/package/stif-boiv-release-#{release_name}.tar HEAD"    sh "bundle package --all" +  sh "bundle exec rake assets:clobber RAILS_ENV=production" +  sh "bundle exec rake assets:precompile RAILS_ENV=production"    sh "tar -rf tmp/package/stif-boiv-release-#{release_name}.tar vendor/cache"    %w{deploy-helper.sh README sidekiq-stif-boiv.service stif-boiv.conf stif-boiv-setup.sh template-stif-boiv.sql}.each do |f|      cp "install/#{f}", "tmp/package/#{f}"    end +  cp "config/environments/production.rb", "tmp/package/production.rb" +    sh "tar -czf stif-boiv-#{release_name}.tar.gz -C tmp/package ."    sh "rm -rf tmp/package vendor/cache"  end | 
