Class: Sunshine::ServerCluster
- Inherits:
-
Array
- Object
- Array
- Sunshine::ServerCluster
- Defined in:
- lib/sunshine/daemons/server_cluster.rb
Overview
The ServerCluster is simply a fancy Array that conveniently forwards some method calls to each server in the array, namely: Server#setup, Server#start, Server#stop, Server#restart, Server#has_setup?, Server#status.
Instance Method Summary collapse
-
#initialize(svr_class, count, app, options = {}) ⇒ ServerCluster
constructor
ServerClusters get initialized just like any server class with the additional svr_class (Unicorn, Thin, Mongrel) and the number of server instances you would like:.
Constructor Details
#initialize(svr_class, count, app, options = {}) ⇒ ServerCluster
ServerClusters get initialized just like any server class with the additional svr_class (Unicorn, Thin, Mongrel) and the number of server instances you would like:
ServerCluster.new Mongrel, 3, app, :port => 5000
#=> [<# mongrel_5000 >, <# mongrel_5001 >, <# mongrel_5002 >]
ServerClusters can also be created from any Server class:
Mongrel.new_cluster 3, app, :port => 5000
23 24 25 26 27 28 29 30 |
# File 'lib/sunshine/daemons/server_cluster.rb', line 23 def initialize svr_class, count, app, ={} count.times do |num| port = ([:port] || 80) + num name = ([:name] || svr_class.short_name) + ".#{port}" self << svr_class.new(app, .merge(:name => name, :port => port)) end end |