Module: Workarea::Configuration::Puma

Extended by:
Puma
Included in:
Puma
Defined in:
lib/workarea/configuration/puma.rb

Instance Method Summary collapse

Instance Method Details

#environmentObject



28
29
30
# File 'lib/workarea/configuration/puma.rb', line 28

def environment
  ENV.fetch('RAILS_ENV') { 'development' }
end

#load(puma) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/workarea/configuration/puma.rb', line 6

def load(puma)
  puma.port(port)
  puma.threads(threads, threads)
  puma.environment(environment)

  if workers.present?
    puma.workers(workers)
    puma.preload_app!
  end

  puma.plugin(:tmp_restart)
  puma.set_remote_address(header: 'X-Real-IP') # For hosted environments
end

#portObject



20
21
22
# File 'lib/workarea/configuration/puma.rb', line 20

def port
  ENV.fetch('PORT') { 3000 }
end

#threadsObject



24
25
26
# File 'lib/workarea/configuration/puma.rb', line 24

def threads
  ENV.fetch('RAILS_MAX_THREADS') { 5 }
end

#workersObject



32
33
34
# File 'lib/workarea/configuration/puma.rb', line 32

def workers
  ENV.fetch('WEB_CONCURRENCY') { nil }
end