Class: Seesaw::Switch

Inherits:
Object
  • Object
show all
Includes:
Mongrel::Command::Base, CommandBase
Defined in:
lib/seesaw/init.rb

Instance Method Summary collapse

Methods included from CommandBase

#log, #parse_options, #restart_http, #restart_mongrels, #shutdown_half_cluster, #start_cluster, #start_mongrels, #stop_mongrels, #switch_to_half_cluster, #symlink

Instance Method Details

#configureObject



114
115
116
117
118
119
# File 'lib/seesaw/init.rb', line 114

def configure 
  options [
    ['-C', '--config PATH', "Path to cluster configuration file", :@config_file, "config/seesaw.yml"],        
    ['', '--cluster CLUSTER', "Switch to cluster configuration CLUSTER: [1|2|all]", :@cluster, 'all']
  ]
end

#runObject



126
127
128
129
130
131
132
133
134
135
136
# File 'lib/seesaw/init.rb', line 126

def run
  parse_options
  unless "all" == @cluster
    @cluster = @cluster.to_i
    other_half = @cluster == 1 ? 2 : 1
  end
  start_mongrels(@cluster)
  symlink(@cluster)
  restart_http
  stop_mongrels(other_half) unless "all" == @cluster
end

#validateObject



121
122
123
124
# File 'lib/seesaw/init.rb', line 121

def validate
  valid?(["1","2","all"].include?(@cluster), "invalid option for --cluster")
  @valid
end