Skip to content

zAdmin Production deployment

Matt Terwilliger edited this page Feb 9, 2021 · 1 revision

As I'm deploying this to production on a new server, it seemed like a good idea to write down some of the gotchas.

No promises on keeping this up to date, but it's better than nothing.

Capistrano is used for deployment.

  • You'll want to set up a new user specifically for deployment, mine's called deploy.
  • You'll need to add an SSH key for this deploy user to your GitHub so it can pull down the repository.
  • You'll need to add your SSH key to the deploy user's authorized_keys for the deploy.
  • Check out config/deploy.rb. A bunch of paths are set in here.
  • Make sure the deploy user has appropriate permissions to the directory to which you're deploying.
  • Once everything's up and running, it's as simple as cap production deploy, which will grab the latest from origin/master, deploy a new revision to production, then activate that revision.

Versioning/dependencies

  • We're currently using ruby 2.6.3. Consider using rvm.
  • The production ActionCable expects a redis server running on localhost.
  • I'm currently proxying requests to a puma socket with nginx.

Configuration

  • All config is stored in environment variables. You'll need to set a slew of them:
    • export RAILS_ENV="production"
    • export EECSHELP_DATABASE="eecshelp_production"
    • export EECSHELP_DATABASE_USER="eecshelp"
    • export EECSHELP_DATABASE_PASSWORD=""
    • export SECRET_KEY_BASE=""
    • export GOOGLE_CLIENT_ID=""
    • export GOOGLE_CLIENT_SECRET=""
    • export GOOGLE_HD="umich.edu"
    • export FULL_HOST="https://oh.eecs.umich.edu"
  • Make sure to lock these down!

Our production server uses SystemD to start puma and populate these environment variables, the unit file is at /etc/systemd/system/puma.service

Troubleshooting

  • If the icons on the site are broken, copy the themes folder from vendor/stylesheets into shared/public. There's a line in config/deploy.rb that will link this folder on every deploy.
  • If you change environment variables, a graceful puma restart does not reload the environment.
  • Rails + puma will go to #{deploy_dir}/current/logs/production.log.
  • You should be able to open a rails production console in #{deploy_dir}/current and get an interpreter with all of the rails environment loaded up.
  • If you notice the statistics page broken, it's probably due to timezone conversion issues. To load timezones into MySQL see this page.