Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support per-tool config file so that one can apply per-tool config fi…

…le permissions.
  • Loading branch information...
commit 17f20cbbf7548ece858ee993d002dfe909cd9ef1 1 parent 9a86180
@FooBarWidget FooBarWidget authored
Showing with 26 additions and 10 deletions.
  1. +2 −1  config.yml.example
  2. +24 −9 shared.rb
View
3  config.yml.example
@@ -34,7 +34,8 @@ monitor-cpu:
check-web-apps:
to: your@gmail.com
from: your@server.com
- subject: Web application %s down
+ # The %s is replaced by the web app's domain name.
+ subject: Web application %s is down
web_apps:
- url: http://app1.com/
substring: Welcome to App1.com.
View
33 shared.rb
@@ -59,17 +59,32 @@ def pv_or_cat
def load_config
require 'yaml'
- filename = "#{TOOLS_DIR}/config.yml"
- if !File.exist?(filename)
- filename = "/etc/phusion-server-tools.yml"
- if !File.exist?(filename)
- abort "*** ERROR: you must create #{TOOLS_DIR}/config.yml or " +
- "/etc/phusion-server-tools.yml. " +
- "Please see #{TOOLS_DIR}/config.yml.example for an example."
+ tool_name = File.basename($0)
+ filenames = [
+ "#{TOOLS_DIR}/config/#{tool_name}.yml",
+ "#{TOOLS_DIR}/config/config.yml",
+ "#{TOOLS_DIR}/config.yml",
+ "/etc/phusion-server-tools/#{tool_name}.yml",
+ "/etc/phusion-server-tools/config.yml",
+ "/etc/phusion-server-tools.yml"
+ ]
+ config_filename = nil
+ filenames.each do |filename|
+ if File.exist?(filename)
+ config_filename = filename
+ break
end
end
- all_config = YAML.load_file(filename)
- $TOOL_CONFIG = all_config[File.basename($0)] || {}
+ if !config_filename
+ STDERR.puts "*** ERROR: you must create a config file at one of the following locations:\n"
+ filenames.each do |filename|
+ STDERR.puts " * #{filename}"
+ end
+ STDERR.puts "Please see #{TOOLS_DIR}/config.yml.example for an example."
+ exit 1
+ end
+ all_config = YAML.load_file(config_filename)
+ $TOOL_CONFIG = (all_config && all_config[tool_name]) || {}
end
def config(name)
Please sign in to comment.
Something went wrong with that request. Please try again.