Skip to content

Commit

Permalink
Merge pull request #125 from pulibrary/production_deploy
Browse files Browse the repository at this point in the history
Add configuration for production deploys.
  • Loading branch information
escowles committed Oct 20, 2016
2 parents f8c58f3 + f455a28 commit 8feccbc
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 8 deletions.
4 changes: 4 additions & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ test:

production:
<<: *defaults
all_collection_manifest_url: <%= ENV["POMEGRANATE_COLLECTIONS_URL"] %>
events:
server: <%= ENV["POMEGRANATE_RABBITMQ_URL"] %>
exchange: <%= ENV["POMEGRANATE_RABBITMQ_EXCHANGE"] %>

staging:
<<: *defaults
3 changes: 3 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ production: &production
<<: *default
adapter: postgresql
database: <%= ENV["POMEGRANATE_DB"] %>
host: <%= ENV["POMEGRANATE_DB_HOST"] %>
username: <%= ENV["POMEGRANATE_DB_USERNAME"] %>
password: <%= ENV["POMEGRANATE_DB_PASSWORD"] %>

staging:
<<: *production
11 changes: 4 additions & 7 deletions config/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# config valid only for current version of Capistrano
lock '3.4.0'

set :application, 'pomegranate'
set :repo_url, 'https://github.com/pulibrary/pomegranate.git'

# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
set :branch, ENV['BRANCH'] || 'master'

# Default deploy_to directory is /var/www/my_app_name
# set :deploy_to, '/var/www/my_app_name'
Expand Down Expand Up @@ -48,20 +45,20 @@

namespace :sneakers do
task :restart do
on roles(:app) do
on roles(:worker) do
execute :sudo, :initctl, :restart, "pom-sneakers"
end
end
end
namespace :sidekiq do
task :quiet do
on roles(:app) do
on roles(:worker) do
# Horrible hack to get PID without having to use terrible PID files
puts capture("kill -USR1 $(sudo initctl status pom-workers | grep /running | awk '{print $NF}') || :")
end
end
task :restart do
on roles(:app) do
on roles(:worker) do
execute :sudo, :initctl, :restart, "pom-workers"
end
end
Expand Down
57 changes: 57 additions & 0 deletions config/deploy/production.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
# You can define all roles on a single server, or split them:

# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
# server 'db.example.com', user: 'deploy', roles: %w{db}
server 'lib-pom1', user: 'deploy', roles: %w(app db web worker)
set :deploy_to, '/opt/rails_app'

# role-based syntax
# ==================

# Defines a role with one or multiple servers. The primary server in each
# group is considered to be the first unless any hosts have the primary
# property set. Specify the username and a domain or IP for the server.
# Don't use `:all`, it's a meta role.

# role :app, %w{deploy@example.com}, my_property: :my_value
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db, %w{deploy@example.com}

# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
# These variables are then only loaded and set in this stage.
# For available Capistrano configuration variables see the documentation page.
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.

# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult the Net::SSH documentation.
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
#
# Global options
# --------------
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
#
# The server-based syntax can be used to override options:
# ------------------------------------
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }
2 changes: 1 addition & 1 deletion config/deploy/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
# server 'db.example.com', user: 'deploy', roles: %w{db}
server 'pom-dev', user: 'deploy', roles: %w(app db web)
server 'pom-dev', user: 'deploy', roles: %w(app db web worker)

# role-based syntax
# ==================
Expand Down

0 comments on commit 8feccbc

Please sign in to comment.