Skip to content

Upgrade the demo server

Charles de Beauchesne edited this page Nov 17, 2019 · 4 revisions

Upgrade API

If you do not need a database model update, here it is :

# Login to demo server
ssh root@demo0.exoscale.infra.camptocamp.org 
cd /root/docker-stuff/composition/demov6/

# Pull down images updates
docker pull c2corg/v6_api:latest # or whatever image is listed on https://hub.docker.com/r/c2corg/v6_api/tags/

# Stop & start everything:
docker-compose stop && docker-compose rm -f
docker-compose up -d

# Make sure everything is up and running:
docker-compose ps

Update the DB model

If a modification has been made on DB model, then do this aftet docker-compose up -d :

docker-compose run --rm api .build/venv/bin/alembic upgrade head

Read logs

NOT TRUE : THERE IS NOTHING IN /VAR/LOG

# "tail -f" on one of the containers listed by the previous command:
docker logs -f demov6_ui_1

# to grep logs from the past, or view haproxy access logs:
docker exec -it demov6_syslog_1 bash # chroot into the syslog container
ls -lR /var/log/2016-* # then grep, tail, etc

Upgrade Images service

Create new tags for in v6_images repositories. We will need them to deploy the validated release on production.

# Login to demo server
ssh root@demo0.exoscale.infra.camptocamp.org 

# get the last migration backup (not relevant anymore)
# scp datamigration.exoscale.infra.camptocamp.org:/root/backups/c2corg.`date +%Y-%m-%d`.dump ~/

cd /root/docker-stuff/composition/demov6/

# check which image flavour is used, update file accordingly:
grep image: docker-compose.yml

# Pull down images updates
docker pull c2corg/v6_images:latest # or whatever image is listed on https://hub.docker.com/r/c2corg/v6_images/tags/

# Stop everything:
docker-compose stop && docker-compose rm -f

# purge old docker images (as we do not have too much disk space)
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi

# this command do not remove tagged images (v6_api and v6_ui) so you have to remove them manually.
docker images
docker rmi <image_hash>

# Restart everything
docker-compose up -d

# Make sure everything is up and running:
docker-compose ps

Now you can send an email to coordination team and testers about the new release with list of changes. Example comparison url: https://github.com/c2corg/v6_ui/compare/v6.0.2...v6.0.3

Upgrade discourse

Stop discourse

ssh root@discourse.exoscale.infra.camptocamp.org

cd /var/discourse
./launcher stop demov6_discourse

exit
...

Restore the new database (not relevant anymore)

ssh root@demo0.exoscale.infra.camptocamp.org 

cd /root/docker-stuff/composition/demov6/
export POSTGRESQL_CONTAINER=`docker-compose ps -q postgresql`

# dump the current database (optional)
# docker exec --user postgres $POSTGRESQL_CONTAINER pg_dump -Fc discourse > /root/backups/discourse_demo.`date +%Y-%m-%d`.dump

docker exec --user postgres $POSTGRESQL_CONTAINER dropdb discourse
docker exec --user postgres $POSTGRESQL_CONTAINER psql -c "CREATE DATABASE discourse OWNER=\"discourse\" ENCODING='UTF8';"
cat /root/backups/discourse.`date +%Y-%m-%d`.dump | \
  docker exec -i --user postgres $POSTGRESQL_CONTAINER pg_restore -d discourse

# update table guidebook.documents_locales in c2corg database
cat ~/update_topic_ids.sql | docker exec -i --user postgres $POSTGRESQL_CONTAINER psql -d c2corg

exit
...

Restart discourse

ssh root@discourse.exoscale.infra.camptocamp.org

# enter discourse container
cd /var/discourse
./launcher start demov6_discourse
./launcher enter demov6_discourse

# upgrade the database
bundle exec rake db:migrate

# enter rails console
rails c

# set SSO settings
SiteSetting.enable_sso = true
SiteSetting.sso_url = "http://www.demov6.camptocamp.org/auth-sso"
SiteSetting.logout_redirect = 'http://www.demov6.camptocamp.org/auth-sso?logout'
SiteSetting.sso_secret="d836444a9e4084d5b224a60c208dce14"

SiteSetting.sso_overrides_username = true
SiteSetting.sso_overrides_name = true
SiteSetting.sso_overrides_email= true

SiteSetting.allow_index_in_robots_txt = false

SiteSetting.global_notice = "Site de démo : tous les nouveaux posts et modifications seront supprimés."

exit
...

Note that topoguide public url should be added as an allowed host in Admin/Settings/Customize/Embedding.

Stopping/restarting the Redis cache

ssh root@demo0.exoscale.infra.camptocamp.org 
cd /root/docker-stuff/composition/demov6/
docker-compose ps
docker-compose stop redis
docker-compose ps
docker-compose start redis
docker-compose ps