require 'rubygems' require 'pathname' require 'thread' require 'bundler' Bundler.require :default require File.expand_path("../worker/ext/string", __FILE__) require File.expand_path("../worker/version", __FILE__) module Evrone module CI module Worker autoload :JobsConsumer, File.expand_path("../worker/consumers/jobs_consumer", __FILE__) autoload :JobLogsConsumer, File.expand_path("../worker/consumers/job_logs_consumer", __FILE__) autoload :JobStatusConsumer, File.expand_path("../worker/consumers/job_status_consumer", __FILE__) autoload :Configuration, File.expand_path("../worker/configuration", __FILE__) autoload :Job, File.expand_path("../worker/job", __FILE__) autoload :Local, File.expand_path("../worker/local", __FILE__) autoload :Docker, File.expand_path("../worker/docker", __FILE__) autoload :CLI, File.expand_path("../worker/cli", __FILE__) autoload :LogJob, File.expand_path("../worker/middlewares/log_job", __FILE__) autoload :UpdateJobStatus, File.expand_path("../worker/middlewares/update_job_status", __FILE__) autoload :LocalCreateDirs, File.expand_path("../worker/middlewares/local_create_dirs", __FILE__) autoload :LocalFetchRepo, File.expand_path("../worker/middlewares/local_fetch_repo", __FILE__) autoload :LocalScript, File.expand_path("../worker/middlewares/local_script", __FILE__) autoload :DockerStartContainer, File.expand_path("../worker/middlewares/docker_start_container", __FILE__) autoload :DockerFetchRepo, File.expand_path("../worker/middlewares/docker_fetch_repo", __FILE__) autoload :DockerScript, File.expand_path("../worker/middlewares/docker_script", __FILE__) autoload :DockerWebdavCache, File.expand_path("../worker/middlewares/docker_webdav_cache", __FILE__) module Helper autoload :Logger, File.expand_path("../worker/helper/logger", __FILE__) autoload :Config, File.expand_path("../worker/helper/config", __FILE__) end extend self @@root = Pathname.new File.expand_path('../../../..', __FILE__) @@config_mutex = Mutex.new def logger if ENV['CI_WORKER_SILENT'] config.null_logger else config.logger end end def configure yield config config end def config @config ||= begin @@config_mutex.synchronize do Configuration.new end end end def root @@root end def perform(job, path_prefix) run_class.new(job, path_prefix).perform end def run_class self.const_get(config.run.to_s.camelize) end def reset_config! @config = nil end def initialize! root.join("lib/evrone/ci/worker/initializers").children.each do |e| require e end end end end end