Last active
August 29, 2015 13:59
-
-
Save chroju/10530987 to your computer and use it in GitHub Desktop.
Capistrano - config/deploy.rb
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
# アプリケーション名 | |
set :application, 'Rails-app' | |
# レポジトリURL | |
set :repo_url, 'git@github.com:chroju/Rails-app' | |
# デプロイ先ディレクトリ | |
set :deploy_to, '/var/www/Rails-app' | |
# SCMを指定 | |
set :scm, :git | |
# logを詳細表示 | |
set :format, :pretty | |
set :log_level, :debug | |
# ssh -tで実行 | |
set :pty, true | |
# currentからsharedへsymlinkを貼るものを指定 | |
set :linked_files, %w{config/database.yml} | |
set :linked_dirs, %w{bin bundle log tmp/pids tmp/cache tmp/sockets public/system} | |
# サーバー上に保持する過去世代数 | |
set :keep_releases, 5 | |
namespace :deploy do | |
desc 'Upload database.yml' | |
task :upload do | |
on roles(:app) do |host| | |
if test "[ ! -d #{shared_path}/config ]" | |
execute "mkdir -p #{shared_path}/config" | |
end | |
upload!('config/database.yml', "#{shared_path}/config/database.yml") | |
end | |
end | |
desc 'Create Database' | |
task :db_create do | |
on roles(:db) do |host| | |
with rails_env: fetch(:rails_env) do | |
within current_path do | |
execute :bundle, :exec, :rake, 'db:create' | |
end | |
end | |
end | |
end | |
desc 'Restart application' | |
task :restart do | |
on roles(:app) do | |
invoke 'unicorn:restart' | |
end | |
end | |
before :starting, :upload | |
after :publishing, :restart | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment