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
• 6,890 points
54 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,280 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,810 points
73 views
0 votes
1 answer

How to get issues count based on rules in a sonar project?

There are API docs in the footer ...READ MORE

answered May 4, 2018 in Other DevOps Questions by DareDev
• 6,810 points
311 views
+1 vote
2 answers

Unable to build TFS project because files not found

Please make a folder in solution Nd ...READ MORE

answered May 16 in Other DevOps Questions by Shashikesh Mishra
505 views
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
145 views
0 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,280 points
35 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,280 points
262 views