0
# Run <tt>thin -h</tt> to get more usage.
0
require File.dirname(__FILE__) + '/../lib/thin'
0
-COMMANDS = %w(start stop restart
)
0
+COMMANDS = %w(start stop restart
config)
0
# Default options values
0
opts.on("-u", "--user NAME", "User to run daemon as (use with -g)") { |user| options[:user] = user }
0
opts.on("-g", "--group NAME", "Group to run daemon as (use with -u)") { |group| options[:group] = group }
0
opts.on( "--prefix PATH", "Mount the app under PATH (start with /)") { |path| options[:prefix] = path }
0
+ opts.on("-C", "--config PATH", "Load option from a config file") { |file| options[:config] = file }
0
opts.separator "Common options:"
0
opts.on_tail("-D", "--debug", "Set debbuging on") { $DEBUG = true }
0
opts.on_tail("-h", "--help", "Show this message") { puts opts; exit }
0
opts.on_tail('-v', '--version', "Show version") { puts Thin::SERVER; exit }
0
-# ==
Commands definitions
0
options[:servers] && options[:servers] > 1
0
+def load_options_from_config_file!(options)
0
+ file = options.delete(:config)
0
+ YAML.load_file(file).each do |key, value|
0
+ options[key.to_sym] = value
0
+# == Commands definitions
0
+ load_options_from_config_file! options
0
Thin::Cluster.new(options).start
0
+ load_options_from_config_file! options
0
Thin::Cluster.new(options).stop
0
+ load_options_from_config_file! options
0
Thin::Cluster.new(options).restart
0
+ config_file = options.delete(:config)
0
+ options.keys.each { |o| options[o.to_s] = options.delete(o) }
0
+ File.open(config_file, 'w') { |f| f << options.to_yaml }
0
+ puts "Wrote configuration to #{config_file}"
0
-
Dir.chdir(options[:chdir])0
+Dir.chdir(options[:chdir])
0
if COMMANDS.include?(command)
Comments
No one has commented yet.