samuelkadolph / unicorn-rails

unicorn-rails is a simple gem that sets the default server for rack (and rails) to unicorn.
MIT License
127 stars 22 forks source link

Environment variable to determine number of worker processes #2

Closed binarycleric closed 11 years ago

binarycleric commented 11 years ago

I ran into a few occasions where I wanted to spin up more worker processes on my development machine. I liked the simplicity of unicorn-rails but I really wanted some way of doing lightweight configuration.

I've been on an "environment as configuration" kick thanks to Heroku so I figured I'd implement worker count that way.

Usage

Spins up 2 worker processes.

$ UNICORN_WORKERS=2 rails server

Still works.

$ rails server
samuelkadolph commented 11 years ago

Hey @binarycleric, thanks for the PR. I preferred your one line solution. There's a fairly nice look way to make it work.

unicorn_options[:worker_processes] = (ENV["UNICORN_WORKERS"] || "1").to_i
binarycleric commented 11 years ago

Updated. Thanks for the help.