Skip to content

Commit

Permalink
Add a new configuration named 'restart_one_by_one' to stop and start …
Browse files Browse the repository at this point in the history
…server one at a time during restart. Set this variable in configuration file to true to make sure that the sever will be restarted one by one
  • Loading branch information
sikachu authored and macournoyer committed Nov 5, 2009
1 parent 69f0ddd commit 3ef09de
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/thin/controllers/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Controllers
class Cluster < Controller
# Cluster only options that should not be passed in the command sent
# to the indiviual servers.
CLUSTER_OPTIONS = [:servers, :only]
CLUSTER_OPTIONS = [:servers, :only, :restart_one_by_one]

# Create a new cluster of servers launched using +options+.
def initialize(options)
Expand All @@ -23,6 +23,7 @@ def pid_file; @options[:pid] end
def log_file; @options[:log] end
def size; @options[:servers] end
def only; @options[:only] end
def restart_one_by_one; @options[:restart_one_by_one] end

def swiftiply?
@options.has_key?(:swiftiply)
Expand Down Expand Up @@ -54,9 +55,14 @@ def stop_server(number)

# Stop and start the servers.
def restart
stop
sleep 0.1 # Let's breath a bit shall we ?
start
unless restart_one_by_one
# Let's do a normal restart by defaults
stop
sleep 0.1 # Let's breath a bit shall we ?
start
else
with_each_server{ |n| stop_server(n); start_server(n); }
end
end

def server_id(number)
Expand Down

0 comments on commit 3ef09de

Please sign in to comment.