Class: Capistrano::Puma

Inherits:
Plugin
  • Object
show all
Includes:
PumaCommon
Defined in:
lib/capistrano/puma.rb

Defined Under Namespace

Classes: Daemon, Jungle, Monit, Nginx, Systemd, Workers

Instance Method Summary collapse

Methods included from PumaCommon

#compiled_template_puma, #puma_bind, #puma_binds, #puma_switch_user, #puma_user, #template_puma

Instance Method Details

#define_tasksObject



97
98
99
# File 'lib/capistrano/puma.rb', line 97

def define_tasks
  eval_rakefile File.expand_path('../tasks/puma.rake', __FILE__)
end

#puma_daemonize?Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/capistrano/puma.rb', line 144

def puma_daemonize?
  fetch(:puma_daemonize)
end

#puma_pluginsObject



148
149
150
151
152
# File 'lib/capistrano/puma.rb', line 148

def puma_plugins
  Array(fetch(:puma_plugins)).collect do |bind|
    "plugin '#{bind}'"
  end.join("\n")
end

#puma_preload_app?Boolean

Returns:

  • (Boolean)


140
141
142
# File 'lib/capistrano/puma.rb', line 140

def puma_preload_app?
  fetch(:puma_preload_app)
end

#puma_workersObject



136
137
138
# File 'lib/capistrano/puma.rb', line 136

def puma_workers
  fetch(:puma_workers, 0)
end

#register_hooksObject



132
133
134
# File 'lib/capistrano/puma.rb', line 132

def register_hooks
  after 'deploy:check', 'puma:check'
end

#set_defaultsObject



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/capistrano/puma.rb', line 101

def set_defaults
  set_if_empty :puma_role, :app
  set_if_empty :puma_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
  # Configure "min" to be the minimum number of threads to use to answer
  # requests and "max" the maximum.
  set_if_empty :puma_threads, [0, 16]
  set_if_empty :puma_workers, 0
  set_if_empty :puma_rackup, -> { File.join(current_path, 'config.ru') }
  set_if_empty :puma_state, -> { File.join(shared_path, 'tmp', 'pids', 'puma.state') }
  set_if_empty :puma_pid, -> { File.join(shared_path, 'tmp', 'pids', 'puma.pid') }
  set_if_empty :puma_bind, -> { File.join("unix://#{shared_path}", 'tmp', 'sockets', 'puma.sock') }
  set_if_empty :puma_control_app, false
  set_if_empty :puma_default_control_app, -> { File.join("unix://#{shared_path}", 'tmp', 'sockets', 'pumactl.sock') }
  set_if_empty :puma_conf, -> { File.join(shared_path, 'puma.rb') }
  set_if_empty :puma_access_log, -> { File.join(shared_path, 'log', 'puma_access.log') }
  set_if_empty :puma_error_log, -> { File.join(shared_path, 'log', 'puma_error.log') }
  set_if_empty :puma_init_active_record, false
  set_if_empty :puma_preload_app, false
  set_if_empty :puma_daemonize, false
  set_if_empty :puma_tag, ''
  set_if_empty :puma_restart_command, 'bundle exec puma'

  # Chruby, Rbenv and RVM integration
  append :chruby_map_bins, 'puma', 'pumactl'
  append :rbenv_map_bins, 'puma', 'pumactl'
  append :rvm_map_bins, 'puma', 'pumactl'

  # Bundler integration
  append :bundle_bins, 'puma', 'pumactl'
end

#upload_puma_rb(role) ⇒ Object



154
155
156
# File 'lib/capistrano/puma.rb', line 154

def upload_puma_rb(role)
  template_puma 'puma', fetch(:puma_conf), role
end