Class: Thin::Commands::Cluster::Config

Inherits:
Base show all
Defined in:
lib/thin/commands/cluster/config.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #trace

Attributes inherited from Thin::Command

#args

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

config_attributes

Methods inherited from Thin::Command

command_name, #initialize

Constructor Details

This class inherits a constructor from Thin::Command

Class Method Details

.detailed_helpObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/thin/commands/cluster/config.rb', line 22

def self.detailed_help
  <<-EOF
usage: thin_cluster config [options]

  Create a configuration file for thin_cluster.
  
  All the options passed to this command will be stored
  in <config> in YAML format.
  
  You can then use this configuration file with the start,
  stop and restart commands with the --config option.
EOF
end

.helpObject



18
19
20
# File 'lib/thin/commands/cluster/config.rb', line 18

def self.help
  "Create a thin_cluster configuration file."
end

Instance Method Details

#runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/thin/commands/cluster/config.rb', line 3

def run
  error 'Config file required' unless config
  
  Dir.chdir cwd if cwd
  
  hash = {}
  self.class.config_attributes.each do |attr|
    hash[attr.to_s] = send(attr)
  end
  
  File.open(config, 'w') { |f| f << YAML.dump(hash) }
  
  puts "Config file created : #{config}"
end