require "bundler/capistrano" #require "capistrano_passenger_deploy" require "unicorn" load 'deploy/assets' set :application, "spree" set :user, 'spree' set :password, "****" set :group, 'www-data' set :rails_env, 'production' set :applicationdir, "/home/#{user}/public_html/mjtb/" server "www.masterjoestoybox.net", :app, :web, :db, :primary => true set :port, **** ssh_options[:port] = **** set :scm, :git set :repository, "git@github.com:Schol-R-LEA/mjtb.git" set :branch, "master" set :deploy_to, "#{applicationdir}#{application}" set :deploy_via, :remote_cache set :use_sudo, false default_run_options[:pty] = true default_run_options[:shell] = '/bin/bash --login' default_environment["RAILS_ENV"] = 'production' set :ssh_options, { :forward_agent => true, :paranoid => false } namespace :foreman do desc "Export the Procfile to Bluepill's .pill script" task :export, :roles => :app do run "cd #{current_path} && bundle exec foreman export --app spree --user spree bluepill #{shared_path}/config" run "cd #{current_path} && bundle exec bluepill load --no-privileged #{shared_path}/config/#{application}.pill" end desc "Start the application services" task :start, :roles => :app do sudo "bluepill #{application} start" end desc "Stop the application services" task :stop, :roles => :app do sudo "bluepill #{application} stop" end desc "Restart the application services" task :restart, :roles => :app do sudo "bluepill #{application} restart" end end namespace :deploy do desc "Symlink shared configs and folders on each release." task :symlink_shared do run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" run "ln -nfs #{shared_path}/config/Procfile #{release_path}/Procfile" run "ln -nfs #{shared_path}/Gemfile #{release_path}/Gemfile" run "ln -nfs #{shared_path}/config/.foreman #{release_path}/.foreman" end end namespace :unicorn do desc "Zero-downtime restart of Unicorn" task :restart, except: { no_release: true } do run "kill -s USR2 `cat /tmp/#{application}.pid`" end desc "Start unicorn" task :start, except: { no_release: true } do run "cd #{current_path} ; bundle exec unicorn_rails -c config/unicorn.rb -D" end desc "Stop unicorn" task :stop, except: { no_release: true } do run "kill -s QUIT `cat /tmp/#{application}.pid`" end end #after "deploy:restart", "unicorn:restart" before 'deploy:assets:precompile', 'deploy:symlink_shared' before 'deploy:start', 'foreman:export' after 'deploy:start', 'foreman:start' after 'foreman:start', 'unicorn:start' before 'deploy:restart', 'foreman:export' #after 'deploy:restart', 'foreman:restart'