Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #18 from hyoshida/hotfix/17_update_production_sett…
Browse files Browse the repository at this point in the history
…ings

本番環境の設定を更新
  • Loading branch information
YOSHIDA Cake committed Nov 7, 2013
2 parents 71d0385 + baf6002 commit 36f685d
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 107 deletions.
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RAILS_ENV=production
SENDGRID_USERNAME=username
SENDGRID_PASSWORD=password
GA_TRACKINGID=UA-xxxxxxxx-x
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
/log/*.log
/tmp

# Ignore dotenv
/.env

/public/assets
*.swp
*~
Expand Down
6 changes: 2 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ group :development do
# Deploy with Capistrano
gem 'capistrano'
gem 'capistrano-rbenv'

# for Heroku
gem 'heroku'
end

# Gems used only for assets and not required
Expand Down Expand Up @@ -109,8 +106,9 @@ gem 'resque'
gem 'private_pub'
gem 'thin'

# 複数アプリケーションの管理
# アプリケーション管理
gem 'foreman'
gem 'bluepill'

# リソース監視
gem 'newrelic_rpm'
Expand Down
22 changes: 7 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ GEM
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
acts_as_follower (0.1.1)
addressable (2.3.5)
arel (3.0.2)
bcrypt-ruby (3.1.1)
bluepill (0.0.66)
activesupport (>= 3.0.0, < 4.0.0)
daemons (~> 1.1.4)
i18n (>= 0.5.0)
state_machine (~> 1.1)
bootstrap-sass (2.3.1.0)
sass (~> 3.2)
builder (3.0.4)
Expand Down Expand Up @@ -114,7 +118,6 @@ GEM
exception_notification (4.0.1)
actionmailer (>= 3.0.4)
activesupport (>= 3.0.4)
excon (0.25.3)
execjs (1.4.0)
multi_json (~> 1.0)
factory_girl (4.2.0)
Expand Down Expand Up @@ -146,14 +149,6 @@ GEM
haml (4.0.0)
tilt
hashie (2.0.5)
heroku (3.0.1)
heroku-api (~> 0.3.7)
launchy (>= 0.3.2)
netrc (~> 0.7.7)
rest-client (~> 1.6.1)
rubyzip
heroku-api (0.3.15)
excon (~> 0.25.1)
highline (1.6.15)
hike (1.2.3)
hpricot (0.8.6)
Expand All @@ -178,8 +173,6 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.8.0)
launchy (2.3.0)
addressable (~> 2.3)
libv8 (3.11.8.13)
mail (2.5.4)
mime-types (~> 1.16)
Expand Down Expand Up @@ -209,7 +202,6 @@ GEM
net-ssh (2.6.5)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
netrc (0.7.7)
newrelic_rpm (3.6.8.168)
nokogiri (1.5.6)
ntlm-http (0.1.1)
Expand Down Expand Up @@ -286,7 +278,6 @@ GEM
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rubyzip (1.0.0)
safe_yaml (0.8.4)
sass (3.2.8)
sass-rails (3.2.6)
Expand Down Expand Up @@ -315,6 +306,7 @@ GEM
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
state_machine (1.2.0)
temple (0.6.5)
term-ansicolor (1.2.2)
tins (~> 0.8)
Expand Down Expand Up @@ -361,6 +353,7 @@ PLATFORMS

DEPENDENCIES
acts_as_follower (~> 0.1.1)
bluepill
bootstrap-sass (~> 2.3.1.0)
capistrano
capistrano-rbenv
Expand All @@ -375,7 +368,6 @@ DEPENDENCIES
font-awesome-sass-rails
foreman
google-analytics-rails
heroku
hpricot
i18n_generators
image_size
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
web: bundle exec rails server -p $PORT
web: sh -c 'bundle exec rails server -p $PORT'
resque: bundle exec rake resque:work QUEUE='*'
private_pub: bundle exec rackup private_pub.ru -s thin -E production
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Clipclap

Clipclap is a tool for collecting and sharing pictures you love.

[Check out a demo](http://clipclap.heroku.com/).
[Check out a demo](http://clipclap.org/).
66 changes: 54 additions & 12 deletions config/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'bundler/capistrano'

set :application, 'clipclap'
set :repository, 'git@49.212.160.224:clipclap.git'
set :repository, 'https://github.com/hyoshida/clipclap.git'
set :deploy_to, "/home/yoshida/public_html/#{application}"
set :rails_env, 'production'
set :user, 'yoshida'
Expand All @@ -10,12 +10,12 @@
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

role :web, '49.212.160.224' # Your HTTP server, Apache/etc
role :app, '49.212.160.224' # This may be the same as your `Web` server
role :db, '49.212.160.224', :primary => true # This is where Rails migrations will run
role :web, 'clipclap.org' # Your HTTP server, Apache/etc
role :app, 'clipclap.org' # This may be the same as your `Web` server
role :db, 'clipclap.org', :primary => true # This is where Rails migrations will run

require 'capistrano-rbenv'
set :rbenv_ruby_version, '2.0.0-p0'
set :rbenv_ruby_version, '2.0.0-p247'

# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"
Expand All @@ -32,16 +32,58 @@
# end
# end

namespace :deploy do
task :start, :roles => :app do
run "cd #{current_path}; bundle exec unicorn_rails -c config/unicorn.rb -E #{rails_env} -D --path /#{application}"
default_run_options[:pty] = true

set :foreman_export_format, 'bluepill'
set :foreman_location_path, "#{shared_path}/bluepill"

namespace :foreman do
desc "Export the Procfile to scripts"
task :export, roles: :app do
run "if [ ! -d #{foreman_location_path} ]; then mkdir -p #{foreman_location_path}; fi"
run "cd #{release_path} && bundle exec foreman export #{foreman_export_format} #{foreman_location_path} #{foreman_format(foreman_options)}"
end

task :restart, :roles => :app do
run "kill -s USR2 `cat #{current_path}/tmp/pids/unicorn.pid`"
def foreman_options
{
app: application,
log: "#{shared_path}/log",
user: user
}
end

task :stop, :roles => :app do
run "kill -s QUIT `cat #{current_path}/tmp/pids/unicorn.pid`"
def foreman_format(opts)
opts.map {|opt,value| "--#{opt}='#{value}'" }.join(' ')
end
end

after 'deploy:update', 'foreman:export'

namespace :bluepill do
desc "Stop processes that bluepill is monitoring and quit bluepill"
task :quit, roles: :app do
run "cd #{release_path} && #{sudo} bundle exec bluepill stop"
run "cd #{release_path} && #{sudo} bundle exec bluepill quit"
end

desc "Load bluepill configuration and start it"
task :start, roles: :app do
run "cd #{current_path} && #{sudo} bundle exec bluepill load #{foreman_location_path}/#{application}.pill"
end

desc "Prints bluepills monitored processes statuses"
task :status, roles: :app do
run "cd #{release_path} && #{sudo} bundle exec bluepill status"
end
end

after "deploy:update", "bluepill:quit", "bluepill:start"

namespace :deploy do
desc "Create a symbolic link .env file to release path"
task :link_dotenv, roles: :app do
run "ln -fns #{shared_path}/config/.env #{release_path}/.env"
end
end

before 'deploy:assets:precompile', 'deploy:link_dotenv'
6 changes: 3 additions & 3 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@
authentication: :plain,
user_name: ENV['SENDGRID_USERNAME'],
password: ENV['SENDGRID_PASSWORD'],
domain: 'heroku.com'
domain: 'clipclap.org'
}

# for Device
config.action_mailer.default_url_options = { :host => 'clipclap.herokuapp.com' }
config.action_mailer.default_url_options = { :host => 'clipclap.org' }

config.middleware.use(
ExceptionNotification::Rack,
email: {
email_prefix: "[Clipclap] ",
sender_address: "Clipclap <noreply@clipclap.herokuapp.com>",
sender_address: %{"Clipclap" <no-reply@clipclap.org>},
exception_recipients: %w( hyoshida@appirits.com )
}
)
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
config.mailer_sender = "noreply@clipclap.herokuapp.com"
config.mailer_sender = "no-reply@clipclap.org"

# Configure the class responsible to send e-mails.
# config.mailer = "Devise::Mailer"
Expand Down
70 changes: 0 additions & 70 deletions config/unicorn.rb

This file was deleted.

0 comments on commit 36f685d

Please sign in to comment.