Execute puma workers only in prod but not in dev environment

0 votes

I'm executing the following puma configuration

threads_count = Integer(ENV["DB_POOL"] || ENV["MAX_THREADS"] || 15)
threads threads_count, threads_count
workers 3
preload_app!

rackup      DefaultRackup
port        ENV["PORT"]     || 3000
environment ENV["RACK_ENV"] || "development"

on_worker_boot do
  ActiveSupport.on_load(:active_record) do
    ActiveRecord::Base.establish_connection
  end
end

before_fork do
  ActiveRecord::Base.connection_pool.disconnect!
end

It works fine for production but I do not want to create 3 workers or use webrick in dev environment. If I try and wrap the worker specific code in env check, it breaks the puma DSL. Any other way I could run puma in non clustered mode in dev.

Aug 16, 2018 in Other DevOps Questions by shubham
• 7,340 points
1,317 views

1 answer to this question.

0 votes

You can us RACK_ENV here instead of Rails as Rails is not defined for puma config.

workers(ENV["RACK_ENV"] == "production" ? 3 : 0)
answered Aug 16, 2018 by ajs3033
• 7,300 points

Related Questions In Other DevOps Questions

0 votes
1 answer

Using conditional to execute a command in salt

You can use unless inside your state ...READ MORE

answered Jul 23, 2018 in Other DevOps Questions by DareDev
• 6,890 points
2,082 views
0 votes
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,040 views
+2 votes
1 answer
0 votes
1 answer

Command not working in .bat script but works in CLI

powershell /? If you run the above command ...READ MORE

answered Jul 19, 2018 in Other DevOps Questions by ajs3033
• 7,300 points
1,537 views
0 votes
1 answer

Puppet not recieving hiera data

Puppet does not consider the variables defined ...READ MORE

answered May 7, 2018 in Other DevOps Questions by ajs3033
• 7,300 points
2,330 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP