diff options
| author | Florent Peyraud | 2017-07-06 12:41:19 +0200 |
|---|---|---|
| committer | Florent Peyraud | 2017-07-06 12:41:19 +0200 |
| commit | 3c39ff76da22a410f1c81acabad626f15a63d800 (patch) | |
| tree | 3469c3198920ee0c0245b330afe1f7f8c2f8278c /install | |
| parent | baaab5943d7102a7f86c000b84644d2fdbabdac7 (diff) | |
| download | chouette-core-3c39ff76da22a410f1c81acabad626f15a63d800.tar.bz2 | |
Update install scripts to cope with the two roles front and worker
Diffstat (limited to 'install')
| -rwxr-xr-x | install/deploy-helper.sh | 22 | ||||
| -rwxr-xr-x | install/stif-boiv-setup.sh | 33 |
2 files changed, 50 insertions, 5 deletions
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" |
