Skip to content

rails integration

Romain Tartière edited this page Jun 6, 2022 · 1 revision

Rails Integration

Deploy a bundled application, run the database migration as the application user and activate it the passenger way:

# site-modules/profile/manifests/application/rails.pp
class profile::application::rails {
  application::kind { 'rails':
    after_deploy_content   => @(SH),
      #!/bin/sh

      set -e

      sudo=''

      if [ -n "${USER_MAPPING_user}" ]; then
        if [ $(id -u) -ne $(id -u "${USER_MAPPING_user}") ]; then
          sudo="sudo -u ${USER_MAPPING_user}"
        fi
      fi

      $sudo RAILS_ENV="${ENVIRONMENT}" SECRET_KEY_BASE="secretsecretsecret" bundle exec rake db:migrate
      | SH
    after_activate_content => @(SH),
      #!/bin/sh

      set -e

      sudo=''

      if [ -n "${USER_MAPPING_user}" ]; then
        if [ $(id -u) -ne $(id -u "${USER_MAPPING_user}") ]; then
          sudo="sudo -u ${USER_MAPPING_user}"
        fi
      fi

      $sudo touch tmp/restart.txt
      | SH
  }
}
Clone this wiki locally