-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:rhysd/daily_coding
- Loading branch information
Showing
11 changed files
with
138 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
load 'deploy' | ||
# Uncomment if you are using Rails' asset pipeline | ||
# load 'deploy/assets' | ||
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } | ||
load 'config/deploy' # remove this line to skip loading any of the default tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,4 @@ $(document).ready -> | |
$('div#answers-unit .gist-part').remove() | ||
$('div#answers-unit').append(data) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
|
||
<div id='answers-body'> | ||
<% @answers.each do |answer| %> | ||
<div class="gist-part" data-src="<%= answer.url + ".json"%>"> | ||
<%== answer.body %> | ||
<% @answers.each do |a| %> | ||
<div class="author"> | ||
<p><a href="#">@<%= a[:author].login %></a></p> | ||
</div> | ||
<div class="gist-part"> | ||
<%== a[:answer].body %> | ||
</div> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
|
||
# capistranoの出力がカラーになる | ||
require 'capistrano_colors' | ||
|
||
# cap deploy時に自動で bundle install が実行される | ||
require "bundler/capistrano" | ||
|
||
# RVMを利用している場合は必要 | ||
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) | ||
require 'rvm/capistrano' | ||
set :rvm_ruby_string, '1.9.2' | ||
set :rvm_type, :user | ||
|
||
# リポジトリの設定 | ||
set :application, "daily_coding" | ||
set :repository, "https://github.com/rhysd/#{application}.git" | ||
set :scm, :git | ||
set :branch, "master" | ||
set :deploy_via, :remote_cache | ||
set :deploy_to, "/var/www/#{application}" | ||
set :rails_env, "production" | ||
|
||
role :web, "www4257uf.sakura.ne.jp:65432" #デプロイ先SSHポートを指定(デフォルトは22) | ||
role :app, "www4257uf.sakura.ne.jp:65432" | ||
role :db, "www4257uf.sakura.ne.jp:65432", :primary => true | ||
|
||
# SSHの設定 | ||
set :user, "y_uuki" | ||
ssh_options[:port] = "65432" | ||
ssh_options[:forward_agent] = true | ||
default_run_options[:pty] = true | ||
|
||
# cap deploy:setup 後、/var/www/ の権限変更 | ||
namespace :setup do | ||
task :fix_permissions do | ||
sudo "chown -R #{user}.#{user} #{deploy_to}" | ||
end | ||
end | ||
after "deploy:setup", "setup:fix_permissions" | ||
|
||
# Unicorn用に起動/停止タスクを変更 | ||
namespace :deploy do | ||
task :start, :roles => :app do | ||
run "cd #{current_path}; bundle exec unicorn_rails -c config/unicorn.rb -E #{rails_env} -D" | ||
end | ||
task :restart, :roles => :app do | ||
if File.exist? "/tmp/unicorn_#{application}.pid" | ||
run "kill -s USR2 `cat /tmp/unicorn_#{application}.pid`" | ||
end | ||
end | ||
task :stop, :roles => :app do | ||
run "kill -s QUIT `cat /tmp/unicorn.pid`" | ||
end | ||
end | ||
|
||
# Rails3.1.1のProduction用 | ||
namespace :assets do | ||
task :precompile, :roles => :web do | ||
run "cd #{current_path} && RAILS_ENV=production bundle exec rake assets:precompile" | ||
end | ||
task :cleanup, :roles => :web do | ||
run "cd #{current_path} && RAILS_ENV=production bundle exec rake assets:clean" | ||
end | ||
end | ||
after :deploy, "assets:precompile" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
application = 'daily_coding' | ||
|
||
listen "/tmp/unicorn_#{application}.sock" | ||
pid "/tmp/unicorn_#{application}.pid" | ||
|
||
worker_processes 6 | ||
preload_app true | ||
|
||
# capistrano 用に RAILS_ROOT を指定 | ||
working_directory "/var/www/#{application}" | ||
|
||
if ENV['RAILS_ENV'] == 'production' | ||
shared_path = "/var/www/#{application}/shared" | ||
stderr_path = "#{shared_path}/log/unicorn.stderr.log" | ||
stdout_path = "#{shared_path}/log/unicorn.stdout.log" | ||
end | ||
|
||
# ログ | ||
stderr_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT']) | ||
stdout_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT']) | ||
|
||
# ダウンタイムなくす | ||
preload_app true | ||
|
||
before_fork do |server, worker| | ||
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! | ||
|
||
old_pid = "#{ server.config[:pid] }.oldbin" | ||
unless old_pid == server.pid | ||
begin | ||
# SIGTTOU だと worker_processes が多いときおかしい気がする | ||
Process.kill :QUIT, File.read(old_pid).to_i | ||
rescue Errno::ENOENT, Errno::ESRCH | ||
end | ||
end | ||
end | ||
|
||
after_fork do |server, worker| | ||
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters