ucsdlib / damspas

UC San Diego DAMS Hydra Head
Other
7 stars 5 forks source link

deploy: restart damsolrizer #673

Closed mcritchlow closed 5 years ago

mcritchlow commented 5 years ago

Fixes issues we're seeing with damspas deploys and NOT restarting damsolrizer.

Example output on a dry run of capistrano w/ this new task added:

~/projects/ucsd/damspas (feature/restart-damsolrizer) % docker-compose -f docker/dev/docker-compose.yml exec web cap production deploy --dry-run
[Deprecation Notice] `set :scm, :git` is deprecated.
To ensure your project is compatible with future versions of Capistrano,
remove the :scm setting and instead add these lines to your Capfile:

    require "capistrano/scm/git"
    install_plugin Capistrano::SCM::Git

00:00 git:wrapper
      01 mkdir -p /tmp
      02 #<StringIO:0x000055974ee47a10> /tmp/git-ssh-damspas-production-.sh
      03 chmod 700 /tmp/git-ssh-damspas-production-.sh
00:00 git:check
      01 git ls-remote https://github.com/ucsdlib/damspas.git HEAD
00:00 deploy:check:directories
      01 mkdir -p /pub/capistrano/shared /pub/capistrano/releases
00:00 git:clone
      The repository mirror is at /pub/capistrano/repo
00:00 git:update
      01 git remote set-url origin https://github.com/ucsdlib/damspas.git
      02 git remote update --prune
00:00 git:create_release
      01 mkdir -p /pub/capistrano/releases/20190703213446
      02 git archive master | /usr/bin/env tar -x -f - -C /pub/capistrano/releases/20190703213446
00:00 deploy:set_current_revision
      01 echo "" >> REVISION
00:00 deploy:migrate
      [deploy:migrate] Run `rake db:migrate`
00:00 deploy:migrating
      01 RBENV_ROOT=$HOME/.rbenv RBENV_VERSION=2.3.7 $HOME/.rbenv/bin/rbenv exec bundle exec rake db:migrate
00:00 whenever:update_crontab
      01 RBENV_ROOT=$HOME/.rbenv RBENV_VERSION=2.3.7 $HOME/.rbenv/bin/rbenv exec bundle exec whenever --update-crontab damspas --set environment=production --roles=web,app,db,sitemap_ping
00:00 deploy:symlink:release
      01 ln -s /pub/capistrano/releases/20190703213446 /pub/capistrano/releases/current
      02 mv /pub/capistrano/releases/current /pub/capistrano
00:00 deploy:write_version
      01 echo `git describe --all --always --long --abbrev=40 HEAD` `date +"%Y-%m-%d %H:%M:%S %Z"`  > /pub/capistrano/releases/20190703213446/public/version.txt
00:00 deploy:update_sitemap
      01 RBENV_ROOT=$HOME/.rbenv RBENV_VERSION=2.3.7 $HOME/.rbenv/bin/rbenv exec bundle exec rake sitemap:refresh
00:00 deploy:assets:precompile
      01 RBENV_ROOT=$HOME/.rbenv RBENV_VERSION=2.3.7 $HOME/.rbenv/bin/rbenv exec bundle exec rake RAILS_RELATIVE_URL_ROOT=/dc assets:precompile
00:00 deploy:restart
      01 mkdir -p /pub/capistrano/releases/20190703213446/tmp
      02 touch /pub/capistrano/releases/20190703213446/tmp/restart.txt
00:00 deploy:restart_damsolrizer
      01 sh $HOME/bin/damsolrizer.sh
00:00 deploy:log_revision
      01 echo "Branch master (at ) deployed as release 20190703213446 by " >> /pub/capistrano/revisions.log

Deployment test to QA

Damspas deployed with a running version of damsolrizer:

[conan@lib-hydrahead-qa ~]$ pgrep -f bin/damsolrizer
4619

Damspas re-deployed w/ this branch:

[conan@lib-hydrahead-qa ~]$ pgrep -f bin/damsolrizer
21057

Note, the PID's change, and damsolrizer is still up and running

Local Checklist

What does this PR do?

Adds a capistrano task to restart damsolrizer on deployment.

@ucsdlib/developers - please review

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.01%) to 65.909% when pulling 4268e93f771466f66227b73b0590317db95f24f6 on feature/restart-damsolrizer into 2bcbc9bfd6200bc25901cf3afb6caf465805b2e2 on master.

rstanonik commented 5 years ago

I modified x.damsolrizier.sh in all environments (qa, staging, production) to use environment variables. It doesn't work in qa because RAILS_ENV for conan isn't set.

mcritchlow commented 5 years ago

@rstanonik - Oh, sorry I missed this comment before making my last commit. So, should I vendor the main damsolrizer script, but leave x.damsolrizer.sh out of it and assume it'll always be in the same place? We can definitely go that route if you'd prefer.

mcritchlow commented 5 years ago

@rstanonik - one thing we could probably do is add a new environment variable for damspas in our environment variables repo that sets the proper host that the script needs. Then we could vendor it and know it would already be setup. Thoughts?

mcritchlow commented 5 years ago

After speaking with @rstanonik and looking at the env vars repo, it seems @jhriv already solved this problem for us :) updating the PR accordingly :)

VivianChu commented 5 years ago

👍

hweng commented 5 years ago

:+1: