Skip to content

Commit

Permalink
Capistrano v3.4 deplyment
Browse files Browse the repository at this point in the history
  • Loading branch information
alexskr committed Jul 7, 2015
1 parent 646d892 commit ec942eb
Show file tree
Hide file tree
Showing 393 changed files with 197 additions and 207,498 deletions.
12 changes: 10 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ gem 'jquery-rails'
# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'
Expand Down Expand Up @@ -57,3 +55,13 @@ gem 'logstash-logger'

gem 'ontologies_api_client', :git => "https://github.com/ncbo/ontologies_api_ruby_client.git", branch: "staging"

group :development do
#Capistrano
gem 'capistrano', '~> 3.4.0', require: false
# rails specific capistrano funcitons
gem 'capistrano-rails', '~> 1.1.0', require: false
# integrate bundler with capistrano
gem 'capistrano-bundler', require: false
# passenger reload
gem 'capistrano-passenger', require: false
end
34 changes: 27 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ GEM
tzinfo (~> 1.1)
arel (6.0.0)
builder (3.2.2)
capistrano (3.4.0)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
capistrano-bundler (1.1.4)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-passenger (0.1.1)
capistrano (~> 3.0)
capistrano-rails (1.1.3)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
coderay (1.1.0)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
Expand All @@ -69,6 +81,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
colorize (0.7.7)
cube-ruby (0.0.3)
dalli (2.7.4)
domain_name (0.5.24)
Expand Down Expand Up @@ -100,7 +113,6 @@ GEM
jquery-ui-rails (5.0.5)
railties (>= 3.2.16)
json (1.8.3)
kgio (2.9.3)
logstash-event (1.1.5)
logstash-logger (0.3.0)
logstash-event
Expand All @@ -117,6 +129,9 @@ GEM
multi_json (1.11.1)
multipart-post (2.0.0)
mysql (2.9.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.2)
netrc (0.10.3)
newrelic_rpm (3.12.1.298)
nokogiri (1.6.6.2)
Expand Down Expand Up @@ -157,7 +172,6 @@ GEM
activesupport (= 4.2.1)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.13.0)
rake (10.4.2)
rake-compiler (0.9.5)
rake
Expand All @@ -183,6 +197,10 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sshkit (1.7.1)
colorize (>= 0.7.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
stackprof (0.2.7)
thor (0.19.1)
thread_safe (0.3.5)
Expand All @@ -195,16 +213,16 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
unicorn (4.9.0)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
will_paginate (3.0.7)

PLATFORMS
ruby

DEPENDENCIES
capistrano (~> 3.4.0)
capistrano-bundler
capistrano-passenger
capistrano-rails (~> 1.1.0)
coffee-rails (~> 4.1.0)
cube-ruby
dalli
Expand Down Expand Up @@ -234,5 +252,7 @@ DEPENDENCIES
sass-rails (~> 5.0)
stackprof
uglifier (>= 1.0.3)
unicorn
will_paginate (~> 3.0)

BUNDLED WITH
1.10.5
109 changes: 82 additions & 27 deletions config/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,38 +1,93 @@
# required for typing in a password for sudo
default_run_options[:pty] = true
# config valid only for Capistrano 3.1
lock '3.4.0'

set :stage, "stage-hostname"
set :user, "SSHUserOnStage"
set :flex_release, "stage"
set :application, 'bioportal_web_ui'

set :application, "BioPortal"
set :repository, "https://bmir-gforge.stanford.edu/svn/bioportalui/trunk"
set :svn_username, "anonymous"
set :svn_password, "anonymous_ncbo"
set :repo_url, "git@github.com:ncbo/#{fetch(:application)}.git"

set :scm, :subversion
#set :deploy_via, :remote_cache

# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
set :deploy_to, "/var/rails/#{application}"
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
NCBO_BRANCH = ENV.include?('NCBO_BRANCH') ? ENV['NCBO_BRANCH'] : 'staging'
set :branch, "#{NCBO_BRANCH}"

# stage
server stage, :app, :web, :db, :primary => true
# Default deploy_to directory is /var/www/my_app
set :deploy_to, "/srv/rails/#{fetch(:application)}"

# production
#role :app, "ror-prod1.example.org"
#role :web, "ror-prod1.example.org"
#role :db, "ror-prod1.example.org", :primary => true
# Default value for :scm is :git
# set :scm, :git

# svn export --force --username anonymous --password anonymous_ncbo https://bmir-gforge.stanford.edu/svn/flexviz/tags/$flexrelease/flex $destination/public/flex
# Default value for :format is :pretty
# set :format, :pretty

# Default value for :log_level is :debug
# set :log_level, :debug

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
set :linked_files, %w{config/bioportal_config.rb config/database.yml public/robots.txt config/newrelic.yml}

# Default value for linked_dirs is []
set :linked_dirs, %w{bin log tmp/pids tmp/cache public/system public/assets config/locales}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5
set :keep_releases, 5
set :bundle_flags, '--without development test --deployment'

#If you want to restart using `touch tmp/restart.txt`, add this to your config/deploy.rb:

set :passenger_restart_with_touch, true
#If you want to restart using `passenger-config restart-app`, add this to your config/deploy.rb:
#set :passenger_restart_with_touch, false # Note that `nil` is NOT the same as `false` here
#If you don't set `:passenger_restart_with_touch`, capistrano-passenger will check what version of passenger you are running
#and use `passenger-config restart-app` if it is available in that version.

# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"

desc 'Incorporate the bioportal_conf private repository content'
#Get cofiguration from repo if ENV NCBO_CONFIG_REPO is set
#(should be set to NCBO private config repo)
task :get_config do
if ENV.include?('NCBO_CONFIG_REPO')
PRIVATE_REPO = ENV['NCBO_CONFIG_REPO']
CONFIG_PATH = "/tmp/#{SecureRandom.hex(15)}"
on roles(:web) do
execute "git clone -q #{PRIVATE_REPO} #{CONFIG_PATH}"
execute "rsync -av #{CONFIG_PATH}/#{fetch(:application)}/ #{fetch(:deploy_to)}/shared"
execute "rm -rf #{CONFIG_PATH}"
## Modify the bioportal_config.rb file for DEPLOY_TARGET on the remote system
# cfg_file = File.join(release_path, "config", "bioportal_config.rb")
# sed_cmd = "\'s/^deploy_target =.*/deploy_target = \"#{DEPLOY_TARGET}\"/\'"
# execute "sed -i -e #{sed_cmd} #{cfg_file}"
end
end
end
end

desc 'Restart application'
task :restart do
on roles(:web), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
execute :touch, release_path.join('tmp/restart.txt')
end
end

before :started, :get_config
after :publishing, :restart

after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end


end
39 changes: 39 additions & 0 deletions config/deploy/production.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary
# server in each group is considered to be the first
# unless any hosts have the primary property set.
# Don't declare `role :all`, it's a meta role
role :app, %w{deploy@example.com}
role :web, %w{deploy@example.com}
role :db, %w{deploy@example.com}

# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server
# definition into the server list. The second argument
# something that quacks like a hash can be used to set
# extended properties on the server.
server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value

# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
# and/or per server
# 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'
# }
# setting per server overrides global ssh_options
39 changes: 39 additions & 0 deletions config/deploy/staging.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary
# server in each group is considered to be the first
# unless any hosts have the primary property set.
# Don't declare `role :all`, it's a meta role
role :app, %w{deploy@example.com}
role :web, %w{deploy@example.com}
role :db, %w{deploy@example.com}

# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server
# definition into the server list. The second argument
# something that quacks like a hash can be used to set
# extended properties on the server.
server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value

# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
# and/or per server
# 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'
# }
# setting per server overrides global ssh_options

This file was deleted.

Loading

0 comments on commit ec942eb

Please sign in to comment.