lock "3.4.0"

set :user, "hacken"
set :application, "hacken-in"
set :repo_url, "https://github.com/hacken-in/website.git"
set :log_level, :info
set :linked_dirs, ["log", "tmp/pids", "tmp/cache", "tmp/sockets", "vendor/bundle", "public/system", "public/uploads"]

set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:stage)}" }
set :deploy_to, "~/#{fetch(:application)}-#{fetch(:stage)}"

set :keep_releases, 5

server "dubhe.uberspace.de", user: fetch(:user), roles: [:app, :db]

namespace :deploy do
  task :restart do
    on roles(:app) do
      within release_path do
        execute "kill -USR2 $(cat tmp/pids/unicorn.pid)"
        execute "kill -WINCH $(cat tmp/pids/unicorn.pid.oldbin)"
      end
    end
  end

  task :migrate do
    on roles(:app) do
      within release_path do
        execute "cd #{release_path}; source ~/hacken-in-#{fetch(:stage)}.secrets; bundle exec rake db:migrate"
      end
    end
  end
end
after "deploy:updated", "deploy:migrate"
after "deploy:published", "deploy:restart"
after "deploy:published", "whenever:update_crontab"

lock "3.4.0"

set :user, "hacken"
set :application, "hacken-in"
set :repo_url, "https://github.com/hacken-in/website.git"
set :log_level, :info
set :linked_dirs, ["log", "tmp/pids", "tmp/cache", "tmp/sockets", "vendor/bundle", "public/system", "public/uploads"]

set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:stage)}" }
set :deploy_to, "~/#{fetch(:application)}-#{fetch(:stage)}"

set :keep_releases, 5

server "dubhe.uberspace.de", user: fetch(:user), roles: [:app, :db]

namespace :deploy do
  task :restart do
    on roles(:app) do
      within release_path do
        execute "kill -USR2 $(cat #{release_path}/tmp/pids/unicorn.pid)"
        execute "kill -WINCH $(cat #{release_path}/tmp/pids/unicorn.pid.oldbin)"
      end
    end
  end

  task :migrate do
    on roles(:app) do
      within release_path do
        execute "cd #{release_path}; source ~/hacken-in-#{fetch(:stage)}.secrets; bundle exec rake db:migrate"
      end
    end
  end
end
after "deploy:updated", "deploy:migrate"
after "deploy:published", "deploy:restart"
after "deploy:published", "whenever:update_crontab"

Fix Capistrano restart task (wrong base dir)
Fix Capistrano restart task (wrong base dir)

Refs #640.
