what is the difference between unicorn and unicorn_rails?
It is officially answered in https://blog.engineyard.com/2010/everything-you-need-to-know-about-unicorn:
What is the unicorn executable? What is the unicorn_rails executable?
The unicorn
executable is a Rack-only tool modeled after Rack’s “rackup” and is recommended for Rack applications. unicorn_rails
was made to be an easier transition for users of pre-Rack versions of Rails. The manpage encourages Rails 3 users to use plain unicorn
instead.
What’s the difference?
From the unicorn_rails
manpage, some conventions of unicorn_rails
are modeled after script/server
found in Rails. It creates directories under “tmp” like script/server
and the -E/–environment
switch sets RAILS_ENV
instead of RACK_ENV
.
Apart from that, in my experience, some gems may need unicorn_rails in particular, like activeadmin (see this)
Also, manpage:
It is designed to help Rails 1.x and 2.y users transition to Rack, but
it is NOT needed for Rails 3 applications. Rails 3 users are
encouraged to use unicorn(1) instead of unicorn_rails(1). Users of
Rails 1.x/2.y may also use unicorn(1) instead of unicorn_rails(1).
difference between passenger and unicorn server
Please read this article about difference of three servers
Rails Server: Passenger, Unicorn or Puma?
New Updates : Puma-vs-Phusion-Passenger
Why does ruby rails need puma or unicorn?
This is not entirely correct, to run PHP with apache you will need either the apache mod_php or run it as a FastCGI module. For Nginx the latter seems to be the norm.
For Ruby there's Phusion Passenger that fills this role, and supports both apache and nginx. On apache it runs as a plugin module just the way mod_php does. For Nginx I'm not sure.
You may want to run your ruby applications using a dedicated application server, however. This is where Unicorn, Puma etc comes in. There's nothing preventing you from doing a similar setup for php, but it's less common.
Another thing which makes php easier to deploy in many cases is that most distros and server installs come with apache and nginx already set up to handle php, while you need to set this up on your own for ruby.
Once set up Passenger makes deploying ruby apps almost (but not quite) as simple as deploying php apps.
Why would I want to use unicorn or thin instead of WEBrick for development purposes?
It is important to develop as closely as possible to the production environment. It helps ensure that an application will work as expected when deployed into production, instead of stumbling upon bugs at runtime.
This issue is alleviated with the use of Continuous Testing on a Build server that replicates the production environment. Even though you are not actively developing on an identical environment, the Continuous Testing gives you coverage that the application is functioning in the expected way.
As to speed, the performance hit running a Rails app in development mode will negate any benefit the various web servers brings.
Why does Unicorn need to be deployed together with Nginx?
Nginx
Unicorn
Refer to unicorn on github for more information.
Referring to Rails from the Unicorn config file
You need to set preload_app true
in your config for the gems like Rails to be accessible from the config file - see here for the documentation.
Related Topics
Upsert Multiple Records with Mongodb
Include Erb Delimiters Inside of a String in an Erb Block
Get Pry to Display Characters Like [äöüßÄÖÜß] (Utf-8 Encoding)? (Possibly Windows-Specific Issue)
Ruby on Rails - $ Rails Server Fails Because Uglifier Gem Could Not Be Found
Ruby Is Already Using the Class Name of My Model
How to Convert 1 to "First", 2 to "Second", and So On, in Ruby
Why Is the << Operation on an Array in Ruby Not Atomic
Can't Run Ruby 2.2.3 with Rvm on Osx
Error When Installing Libv8 3.11.8.3
If 'Self' Is Always the Implied Receiver in Ruby, Why Doesn't 'Self.Puts' Work
Post Redirect Get Pattern in Rails
Ruby Converting Utc to User's Time Zone
Nokogiri Issues with Ruby on Rails
Ruby on Rails: Params Is Nil. Undefined Method '[]' for Nil:Nilclass
Bundle Uses Wrong Ruby Version
What Is the Advantage of Creating an Enumerable Object Using To_Enum in Ruby