Module: LWAC
- Defined in:
- lib/lwac.rb,
lib/lwac/client.rb,
lib/lwac/export.rb,
lib/lwac/import.rb,
lib/lwac/server.rb,
lib/lwac/export/format.rb,
lib/lwac/client/storage.rb,
lib/lwac/server/db_conn.rb,
lib/lwac/shared/multilog.rb,
lib/lwac/export/resources.rb,
lib/lwac/client/file_cache.rb,
lib/lwac/shared/data_types.rb,
lib/lwac/shared/serialiser.rb,
lib/lwac/shared/launch_tools.rb,
lib/lwac/server/storage_manager.rb,
lib/lwac/export/key_value_format.rb,
lib/lwac/server/consistency_manager.rb
Overview
LWAC namespace
Defined Under Namespace
Modules: Identity, KeyValueFormat, OutputFilter Classes: CSVFormatter, ConsistencyManager, DataPoint, DatabaseConnection, DatabaseStorageManager, DownloadClient, DownloadServer, DownloadService, Exporter, FileCache, Formatter, Importer, JSONFormatter, KeyValueFormatter, Link, MultiCSVFormatter, MultiOutputLogger, MultiTemplateFormatter, MultiXMLFormatter, MySQLDatabaseConnection, Resource, SQLite3DatabaseConnection, Sample, Serialiser, ServerState, StorageManager, Store
Constant Summary collapse
- VERSION =
Overall LWAC version, as in the git tags
'0.2.0'
- DATE =
Date of last significant edit
'20-07-13'
- AUTHORS =
Authors
[ {:name => "Stephen Wattam", :contact => "http://stephenwattam.com"}, #{:name => "", :contact => ""} # Add yourself here (and in the gemspec) if you contribute to LWAC ]
- RESOURCE_DIR =
Location of resources
File.join( File.dirname( File.(__FILE__) ), '../resources/')
Class Method Summary collapse
-
.load_config ⇒ Object
—————————————————————————– Load configs from ARGV and output usage info.
- .print_usage ⇒ Object
Class Method Details
.load_config ⇒ Object
Load configs from ARGV and output usage info.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/lwac/shared/launch_tools.rb', line 24 def self.load_config # First, check arguments are fine. if ARGV.length < 2 or not File.readable?(ARGV[1]) then print_usage() exit(1) end # Check the tool is a valid one if not %w{server client import export}.include?(ARGV[0]) then $stderr.puts "Not a valid command: #{ARGV[0]}" print_usage() exit(1) end # Require things we need for the below require 'yaml' require 'logger' # Then check filesystem is in shape #require_relative ... # Then load the config tool = ARGV[0].to_sym config = YAML.load_file(ARGV[1]) # Then, create global log logdevs = [] if config[:logging] and config[:logging][:logs].is_a?(Hash) config[:logging][:logs].each{|name, ldopts| # Construct the log ld = {:name => name} ld[:dev] = %w{STDOUT STDERR}.include?(ldopts[:dev]) ? eval(ldopts[:dev]) : ldopts[:dev] || STDOUT ld[:level] = ldopts[:level] # Add to the list of logs logdevs << ld } end $log = MultiOutputLogger.new(logdevs, config[:logging][:progname].to_s) # Apply nicer log output format $log.formatter = proc do |severity, datetime, progname, msg| "#{severity.to_s[0]} #{progname} [#{datetime.strftime('%y-%m-%d %H:%M:%S')}] #{msg}\n" end # Handle signals nicely. $log.debug "Installing signal handlers..." %w{INT HUP KILL ABRT}.each{|s| trap(s) { raise SignalException.new(s) } } # Return the config we've loaded. return tool, config end |
.print_usage ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/lwac/shared/launch_tools.rb', line 12 def self.print_usage $stderr.puts "USAGE: #{$PROGRAM_NAME} TOOL CONFIG [IMPORT_FILE]" $stderr.puts "" $stderr.puts " TOOL : one of 'server', 'client', 'import' or 'export'" $stderr.puts " CONFIG : A path to the config file for the tool" $stderr.puts " IMPORT_FILE : A URL list to import" $stderr.puts "" end |