2014-03-23 00:22:25 +00:00
|
|
|
lock '3.1.0'
|
|
|
|
|
|
|
|
set :application, 'ensl'
|
2014-03-25 11:15:49 +00:00
|
|
|
set :deploy_via, :remote_cache
|
2014-03-23 04:13:19 +00:00
|
|
|
set :pty, true
|
|
|
|
|
2014-03-23 00:22:25 +00:00
|
|
|
set :scm, :git
|
2014-04-12 01:35:42 +00:00
|
|
|
set :repo_url, 'https://github.com/ENSL/ensl.org.git'
|
2014-03-23 00:22:25 +00:00
|
|
|
set :keep_releases, 10
|
|
|
|
|
|
|
|
set :rbenv_type, :user
|
2014-06-16 14:10:41 +00:00
|
|
|
set :rbenv_ruby, '2.1.2'
|
|
|
|
set :bundle_flags, '--quiet'
|
2014-03-25 14:44:42 +00:00
|
|
|
set :dotenv_role, [:app, :web]
|
2014-03-23 04:13:19 +00:00
|
|
|
|
2014-04-15 22:04:43 +00:00
|
|
|
set :puma_config, -> { File.join(current_path, 'config', 'puma.rb') }
|
2014-04-15 09:59:52 +00:00
|
|
|
set :puma_pid, -> { File.join(shared_path, 'tmp', 'pids', 'puma.pid') }
|
2014-03-25 11:15:49 +00:00
|
|
|
|
|
|
|
set :writable_dirs, %w{public tmp}
|
2014-03-23 04:13:19 +00:00
|
|
|
set :linked_files, %w{.env}
|
|
|
|
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle
|
2014-03-30 19:50:52 +00:00
|
|
|
public/system public/local public/uploads public/files}
|
2014-03-23 04:13:19 +00:00
|
|
|
|
2014-03-25 11:15:49 +00:00
|
|
|
set :normalize_asset_timestamps, %{public/images
|
|
|
|
public/javascripts
|
|
|
|
public/stylesheets}
|
2014-03-23 00:22:25 +00:00
|
|
|
|
|
|
|
namespace :deploy do
|
2014-03-24 14:23:08 +00:00
|
|
|
namespace :check do
|
|
|
|
desc "Check write permissions"
|
|
|
|
task :permissions do
|
|
|
|
on roles(:all) do |host|
|
|
|
|
fetch(:writable_dirs).each do |dir|
|
|
|
|
path = "#{shared_path}/#{dir}"
|
|
|
|
|
|
|
|
if test("[ -w #{path} ]")
|
|
|
|
info "#{path} is writable on #{host}"
|
|
|
|
else
|
|
|
|
error "#{path} is not writable on #{host}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-03-23 00:22:25 +00:00
|
|
|
task :restart do
|
2014-04-15 09:59:52 +00:00
|
|
|
invoke 'puma:restart'
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
after :publishing, :restart
|
2014-04-15 09:59:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
namespace :puma do
|
|
|
|
desc "Start puma"
|
|
|
|
task :start do
|
|
|
|
on roles(:app) do
|
|
|
|
within current_path do
|
|
|
|
execute :bundle, 'exec', :puma, "-C #{fetch(:puma_config)}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Restart puma"
|
|
|
|
task :restart do
|
|
|
|
on roles(:app) do
|
|
|
|
within current_path do
|
|
|
|
if valid_pid?
|
|
|
|
execute :kill, "-USR2 $( cat #{fetch(:puma_pid)} )"
|
|
|
|
else
|
|
|
|
execute :bundle, 'exec', :puma, "-C #{fetch(:puma_config)}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Stop puma"
|
|
|
|
task :stop do
|
|
|
|
on roles(:app) do
|
|
|
|
within current_path do
|
|
|
|
if valid_pid?
|
|
|
|
execute :kill, "-INT $( cat #{fetch(:puma_pid)} )"
|
|
|
|
else
|
|
|
|
warn 'Puma does not appear to be running'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def valid_pid?
|
|
|
|
test "[ -f #{fetch(:puma_pid)} ]" and test "kill -0 $( cat #{fetch(:puma_pid)} )"
|
|
|
|
end
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|