Sha256: 3a56708e573d44314c2961317065e11cb2dc40d53cb058308d70129b4edaa8af

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require 'json'
require 'logger'
require "base64"

require "prepare-environment"
require "trace-runner"

class HelperRun
    def initialize ()
        @basePath = Pathname.new(Canzea::config[:catalog_location]).realpath
        @log = Logger.new(Canzea::config[:logging_root] + '/plans.log')
    end

    def runPlan (plans)
        plans.each { | plan |
            puts "Running #{plan[:action]}"
            self.run plan[:solution], plan[:action], plan[:parameters]
        }
    end

    def run (solution, action, parameters)

        type = "ruby"

        #parameters = JSON.generate(parameters)

        envPush = PrepareEnvironment.new

        begin
            envScript = "#{@basePath}/helpers/#{solution}/environment.json"
            if File.exist?(envScript)
                @log.info("Adding environment variables...")
                envPush.addToEnv "#{envScript}"
            end

            r = RunnerWorker.new

            ENV['CATALOG_LOCATION'] = "#{@basePath}";

            if (type == "ruby")
                cmd = "ruby #{@basePath}/helpers/#{solution}/#{action}.rb '#{parameters}'"
            else
                cmd = "#{@basePath}/helpers/#{solution}/#{action}.sh \"#{parameters}\""
            end
            r.run cmd, 1, 1, false

        rescue => exception
            @log.error(cmd)
            @log.error(exception.to_s)
            @log.error(exception.backtrace)
            abort()
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
canzea-0.1.26 lib/helper-run-class.rb
canzea-0.1.25 lib/helper-run-class.rb