Tag: Capistrano3/Tips
#> 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
# If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac