How to determine which server (thin, cougar, passenger, ...) is used for the Rails application?

I need to do some initialization depending on the web server that is used to run the application. Is it possible to programmatically determine from a rail initializer?

+6
source share
4 answers

Even if it’s not so clean, you can use

defined?(::Thin) defined?(::Unicorn) defined?(::Passanger) 

etc. This will work for the three, and you should check if it works with others.

+1
source

Here is a kind of hacker way to do this (add to config/application.rb ):

 module Rails class Server < ::Rack::Server alias_method :old_start, :start def start puts server.name # or set an ENV variable old_start end end end 
0
source

You can check if the process is working or not using ps aux

 ps aux | grep passenger ps aux | grep puma ps aux | grep unicorm 
0
source

I just finished using https://www.builtwith.com , it gives all the necessary information.

-1
source

Source: https://habr.com/ru/post/969756/


All Articles