Tag: Capistrano3
#> dbサーバーのデータベースを生成するタスク。 #> デプロイ前に実行する必要がある。 task :db_create do on roles(:db) do |host| q1 = 'CREATE DATABASE IF NOT EXISTS <app_name>;' q2 = 'GRANT ALL ON <app_name>.* TO <app_user>@localhost IDENTIFIED BY "<app_passsword>";' q3 = "FLUSH PRIVILEGES;" sql = "#{q1}#{q2}#{q3}" execute "mysql --user=<mysql_user> --password=<msql_password> -e '#{sql}' " end end
namespace :deploy do after :restart, :restart_passenger do on roles(:web), in: :groups, limit: 3, wait: 10 do within release_path do execute :touch, 'tmp/restart.txt' end end end after :finishing, 'deploy:restart_passenger' end end
set :rails_env, "staging"
bundle exec rails s -e staging
bundle exec cap staging deploy
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/uploads')
bundle config github.com *********:x-oauth-basic
export BUNDLE_GITHUB__COM=******:x-oauth-basic
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 is a, or duck-types, Hash and is # used to set extended properties on the server. server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value