[Aaron-devel-cvs] CVS: aaron/src/main aaron.rb,1.2,1.3
Status: Pre-Alpha
                
                Brought to you by:
                
                    thetitan
                    
                
            | 
     
      
      
      From: Sean C. <the...@us...> - 2001-07-05 21:34:23
      
     
   | 
Update of /cvsroot/aaron/aaron/src/main
In directory usw-pr-cvs1:/tmp/cvs-serv24523
Modified Files:
	aaron.rb 
Log Message:
Added inline RD documentation for aaron.  You can create the manpage now by:
rd2 -rrd/rd2man-lib.rb aaron.rb > aaron.man
Index: aaron.rb
===================================================================
RCS file: /cvsroot/aaron/aaron/src/main/aaron.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** aaron.rb	2001/07/05 11:03:16	1.2
--- aaron.rb	2001/07/05 21:34:20	1.3
***************
*** 61,64 ****
--- 61,72 ----
  #	Main file from which aaron runs
  
+ =begin
+ = NAME
+ aaron - Transaction Scheduling and exception handling machine
+ = SYNOPSIS
+ aaron [ ((*options*)) ]
+ == INTRODUCTION
+ ((*aaron*)) is an event scheduling and exception handling machine. ((*aaron*)) has a complex rules engine that makes it ideal for both monitoring of service, but also for scheduling the execution of events (ie: cron jobs).
+ =end
  
  # Global includes/requires
***************
*** 70,130 ****
  
  
! # Loads the file paths for all of the remaining configuration and libraries.
! # The phase one config file is required otherwise Aaron will not know where to
! # go inorder to find the remaining configuration files and misc modules.
! def loadPathConfig(config, path_config_file_name = "./paths.conf")
!   unless File.readable?(path_config_file_name)
!     $stderr.printf("ERROR[loadPathConfig]: The path config file \"%s\" does not exist.\n\n", path_config_file_name)
!     printHelp()
!     exit(1)
!   end
! 
!   # Load the file and parse out comments and blank lines
!   IO.foreach(path_config_file_name) do |line|
!     next if /\A\s*\#/ =~ line  # comments
!     line.gsub!(/\A\s+\z/, '')  # blank lines
!     next if line.empty?        # empty lines
!     /(.*?)\s*=\s*(.*)/ =~ line # find key/value pairs
!     config[$1] = $2
!   end
! 
!   # Expand out the various *_mod_dirs
!   config["action_mod_dir"] = config["module_path"] + "/" + config["action_mod_dir"]
!   config["response_mod_dir"] = config["module_path"] + "/" + config["response_mod_dir"]
!   config["transaction_mod_dir"] = config["module_path"] + "/" + config["transaction_mod_dir"]
! 
! 
!   return(config)
! end
! 
! 
! 
! # Prints out debugging level information
! def printDebugLevel(config)
!   print "Debug level: " << config["debug"].to_s << "\n"
! end
! 
! 
! 
! # Prints out a usage/help message
! def printHelp()
!   printf("Usage: %s [OPTIONS]\n", $0)
!   print "  -h, --help\t\tDisplay this help and exit.\n"
!   print "  -d, --debug [n]\tSet debug level to 'n'\n"
!   print "  -c, --config <config>\tPath to phase one aaron config (default \"./path.conf\")\n"
!   print "  -V, --version\t\tDisplay aaron version information\n\n"
! end
! 
! 
! 
! # Prints out the version of aaron.
! # This should pull the sticky tag, but the file's revision will work for now
! def printVersion()
!   version = "$Revision 1.0 $"
!   version = version.scan(/\$\s*Revision\s*(.*?)\s*\$/)
!   printf("%s Ver: %s\n", $0, version)
! end
! 
! 
  # Function responsible for processing arguments and setting up config
  def processArgs(config)
--- 78,94 ----
  
  
! =begin
! = COMMAND-LINE OPTIONS
! --- -c|--config=file
!     File that aaron uses when it first loads.  This file is a necessary
!     evil because aaron is currently an interpreted program and not compiled.
! --- -d|--debug[=level]
!     Set the debugging level.  If no ((*level*)) is specified, then the
!     debug level is set to (({1})).
! --- -h|--help
!     Display a help/usage message and exit.
! --- -V|--version
!     Print the ((*aaron*)) version number and exit.
! =end
  # Function responsible for processing arguments and setting up config
  def processArgs(config)
***************
*** 134,139 ****
    begin
      opts = GetoptLong.new(
-              [ "--debug", "-d",   GetoptLong::OPTIONAL_ARGUMENT ],
               [ "--config", "-c",  GetoptLong::REQUIRED_ARGUMENT ],
               [ "--help", "-h",    GetoptLong::NO_ARGUMENT ],
               [ "--version", "-V", GetoptLong::NO_ARGUMENT ]
--- 98,103 ----
    begin
      opts = GetoptLong.new(
               [ "--config", "-c",  GetoptLong::REQUIRED_ARGUMENT ],
+              [ "--debug", "-d",   GetoptLong::OPTIONAL_ARGUMENT ],
               [ "--help", "-h",    GetoptLong::NO_ARGUMENT ],
               [ "--version", "-V", GetoptLong::NO_ARGUMENT ]
***************
*** 182,186 ****
--- 146,227 ----
  
    return(config)
+ end  # End processArgs()
+ 
+ 
+ # Prints out a usage/help message
+ def printHelp()
+   printf("Usage: %s [OPTIONS]\n", $0)
+   print "  -h, --help\t\tDisplay this help and exit.\n"
+   print "  -d, --debug [n]\tSet debug level to 'n'\n"
+   print "  -c, --config <config>\tPath to phase one aaron config (default \"./path.conf\")\n"
+   print "  -V, --version\t\tDisplay aaron version information\n\n"
+ end  # End printHelp
+ 
+ 
+ 
+ =begin
+ =PHASE ONE CONFIG
+ The phase one config file is a simple configuration file that is required by
+ ((*aaron*)) to tell the program where configuration files and modules are, as
+ well as the names of the module directories (stats, event, response, etc.).
+ All information set by phase one configuration directives can be overridden
+ later by subsequent configuration directives.
+ ==PHASE ONE CONFIG FILE FORMAT
+ The phase one config has a simple format.  All lines beginning with a (({#})) are ignored.  All lines with spaces are ignored. All information in this file is stored in key/value pairs separated by (({=})) signs.
+ ==PHASE ONE CONFIG VARIABLES
+ --- module_path
+     Required. The path to the base modules directory.
+ --- action_mod_dir
+     Optional. Name of the directory within the ((*modules*)) directory that has ((*action*)) modules.  Defaults to (({action})).
+ --- response_mod_dir
+     Optional.  Name of the directory within the ((*modules*)) directory that has ((*response*)) modules.  Defaults to (({response})).
+ --- transaction_mod_dir
+     Optional.  Name of the directory within the ((*modules*)) directory that has ((*transaction*)) modules.  Defaults to (({transaction})).
+ =end
+ def loadPathConfig(config, path_config_file_name = "./paths.conf")
+   unless File.readable?(path_config_file_name)
+     $stderr.printf("ERROR[loadPathConfig]: The path config file \"%s\" does not exist.\n\n", path_config_file_name)
+     printHelp()
+     exit(1)
+   end
+ 
+   # Load the file and parse out comments and blank lines
+   IO.foreach(path_config_file_name) do |line|
+     next if /\A\s*\#/ =~ line  # comments
+     line.gsub!(/\A\s+\z/, '')  # blank lines
+     next if line.empty?        # empty lines
+     /(.*?)\s*=\s*(.*)/ =~ line # find key/value pairs
+     config[$1] = $2
+   end
+ 
+   # Expand out the various *_mod_dirs
+   config["action_mod_dir"] = config["module_path"] + "/" + config["action_mod_dir"]
+   config["response_mod_dir"] = config["module_path"] + "/" + config["response_mod_dir"]
+   config["transaction_mod_dir"] = config["module_path"] + "/" + config["transaction_mod_dir"]
+ 
+ 
+   return(config)
+ end
+ 
+ 
+ 
+ # Prints out debugging level information
+ def printDebugLevel(config)
+   print "Debug level: " << config["debug"].to_s << "\n"
  end
+ 
+ 
+ 
+ =begin
+ =VERSION
+ $Revision 1.0 $
+ =end
+ # This should pull the sticky tag, but the file's revision will work for now
+ def printVersion()
+   version = "$Revision 1.0 $"
+   version = version.scan(/\$\s*Revision\s*(.*?)\s*\$/)
+   printf("%s Ver: %s\n", $0, version)
+ end
+ 
  
  
 |