Sha256: c31378e2543e9372c499d8d7dce4ebe39e466a65f801b324a210fa0d046b503b

Contents?: true

Size: 1.87 KB

Versions: 4

Compression:

Stored size: 1.87 KB

Contents

require 'rbatch/variables'
require 'rbatch/journal'
require 'rbatch/run_conf'
require 'rbatch/double_run_checker'
require 'rbatch/log'
require 'rbatch/config'
require 'rbatch/cmd'

module RBatch
  class Controller
    attr :vars,:config,:common_config,:journal,:user_logs
    def initialize
      @vars = RBatch::Variables.new()
      RBatch::Journal.def_vars = @vars
      RBatch::Log.def_vars = @vars
      RBatch::Cmd.def_vars = @vars
      @journal = RBatch::Journal.new()
      RBatch::Log.journal = @journal
      @user_logs = []
      @journal.put 1,"=== START RBatch === (PID=#{$$.to_s})"
      @journal.put 1, "RB_HOME : \"#{@vars[:home_dir]}\""
      @journal.put 1, "Load Run-Conf: \"#{@vars[:run_conf_path]}\""
      @journal.put 2, "RBatch Variables : #{@vars.inspect}"
      @common_config = RBatch::Config.new(@vars[:common_config_path])
      @journal.put 1, "Load Config  : \"#{@vars[:common_config_path]}\"" if @common_config.exist?
      @config = RBatch::Config.new(@vars[:config_path])
      @journal.put 1, "Load Config  : \"#{@vars[:config_path]}\"" if @config.exist?

      # double_run_check
      if ( @vars[:forbid_double_run])
        RBatch::DoubleRunChecker.check(@pvars[:rogram_base]) #raise error if check is NG
        RBatch::DoubleRunChecker.make_lock_file(@vars[:program_base])
      end
      # load_lib
      if @vars[:auto_lib_load] && Dir.exist?(@vars[:lib_dir])
        Dir::foreach(@vars[:lib_dir]) do |file|
          if /.*rb/ =~ file
            require File.join(@vars[:lib_dir],File.basename(file,".rb"))
            @journal.put 1, "Load Library : \"#{File.join(@vars[:lib_dir],file)}\" "
          end
        end
      end
      @journal.put 1, "Start Script : \"#{@vars[:program_path]}\""
    end #end def
    def config ; @config ; end
    def common_config ; @common_config ; end
    def cmd(cmd_str,opt)
      RBatch::Cmd.new(cmd_str,opt).run
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rbatch-2.1.6 lib/rbatch/controller.rb
rbatch-2.1.5 lib/rbatch/controller.rb
rbatch-2.1.4 lib/rbatch/controller.rb
rbatch-2.1.3 lib/rbatch/controller.rb