Skip to content

Commit

Permalink
Changing puma configuration to work on server
Browse files Browse the repository at this point in the history
  • Loading branch information
c-brooks committed Nov 9, 2016
1 parent bc93ac2 commit a49b820
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
15 changes: 15 additions & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@
set :whenever_command, "bundle exec whenever"
set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:stage)}" }

# Puma Configuration
set :pty, true
set :use_sudo, true
set :deploy_via, :remote_cache
set :deploy_to, "/home/deploy/#{fetch(:application)}"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.stdout.log"
set :puma_error_log, "#{release_path}/log/puma.stderr.log"
# set :ssh_options, { for ward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true # Change to false when not using ActiveRecord

# Default value for :scm is :git
# set :scm, :git

Expand Down
7 changes: 6 additions & 1 deletion config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@
require "active_record"
ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
require 'erb'
ActiveRecord::Base.establish_connection( YAML.load( ERB.new( File.read( "#{app_dir}/config/database.yml" )).result)[rails_env])end
if YAML.load( ERB.new( File.read( "#{app_dir}/config/database.yml" )).result)[rails_env]
ActiveRecord::Base.establish_connection( YAML.load( ERB.new( File.read( "#{app_dir}/config/database.yml" )).result)[rails_env])
else
# On the server -> do nothing for now
end
end
17 changes: 14 additions & 3 deletions lib/capistrano/tasks/setup.rake
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,24 @@ namespace :setup do
end
end

desc "Symlinks config files for Nginx and Unicorn."
desc 'Create Directories for Puma Pids and Socket'
task :make_dirs do
on roles(:app) do
execute "mkdir #{shared_path}/tmp/sockets -p"
execute "mkdir #{shared_path}/tmp/pids -p"
execute "mkdir #{release_path}/shared/log -p"
execute "touch #{release_path}/shared/log/puma.stdout.log"
execute "touch #{release_path}/shared/log/puma.stderr.log"
end
end

desc "Symlinks config files for Nginx."
task :symlink_config do
on roles(:app) do
execute "rm -f /etc/nginx/sites-enabled/default"

execute "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{fetch(:application)}"
execute "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{fetch(:application)}"
end
end
end

end

0 comments on commit a49b820

Please sign in to comment.