Skip to content

Commit

Permalink
simplify stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
svenfuchs committed Jan 26, 2013
1 parent 09c7db1 commit abe8cea
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 453 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -6,4 +6,3 @@ log/*
*.class
.rbenv-version
.rbenv-gemsets
bin/
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -21,6 +21,7 @@ gem 'sidekiq'
gem 'hot_bunnies', '~> 1.4.0.pre4'
gem 'jruby-openssl', '~> 0.7.7'

# see http://www.ruby-forum.com/topic/4409725
gem 'activerecord-jdbcpostgresql-adapter', '= 1.2.2.1'

gem 'coder', github: 'rkh/coder'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Expand Up @@ -42,7 +42,7 @@ GIT

GIT
remote: git://github.com/travis-ci/travis-core.git
revision: 871129e3b8002b8c6299ad0dd04e74a7632fc148
revision: e428d0b42fad2834ad187c9b3860bb77ec7d13c9
specs:
travis-core (0.0.1)
actionmailer (~> 3.2.11)
Expand Down Expand Up @@ -71,7 +71,7 @@ GIT

GIT
remote: git://github.com/travis-ci/travis-support.git
revision: cf916e10949db43ce6f2b6f86082b367f04acfcd
revision: ff712aca1083a588974f835a84c574e6976aeb29
specs:
travis-support (0.0.1)

Expand Down
2 changes: 1 addition & 1 deletion Procfile
@@ -1 +1 @@
hub: bin/thor travis:hub:start
hub: ./bin/hub
6 changes: 0 additions & 6 deletions Thorfile

This file was deleted.

18 changes: 18 additions & 0 deletions bin/hub
@@ -0,0 +1,18 @@
#! /usr/bin/env ruby

$stdout.sync = true

$: << 'lib'

require 'bundler/setup'
require 'travis/hub'
require 'core_ext/module/load_constants'

[Travis::Hub, Travis].each do |target|
target.load_constants!(:skip => [/::AssociationCollection$/], debug: false)
end

app = Travis::Hub.new
app.setup
app.run

82 changes: 37 additions & 45 deletions lib/travis/hub.rb
@@ -1,68 +1,60 @@
require 'multi_json'
require 'benchmark'
require 'active_support/core_ext/float/rounding'
require 'core_ext/kernel/run_periodically'
require 'core_ext/hash/compact'

require 'travis'
require 'travis/support'
require 'core_ext/kernel/run_periodically'

$stdout.sync = true

module Travis
class Hub
autoload :Handler, 'travis/hub/handler'
autoload :Instrument, 'travis/hub/instrument'
autoload :Error, 'travis/hub/error'
autoload :Queues, 'travis/hub/queues'

include Logging
autoload :Error, 'travis/hub/error'
autoload :Queue, 'travis/hub/queue'

class << self
def start
setup
prune_workers
enqueue_jobs
extend Instrumentation

Travis::Hub::Queues.subscribe
end

protected
def setup
Travis::Async.enabled = true
Travis::Amqp.config = Travis.config.amqp

def setup
Travis::Features.start
Travis::Database.connect
Travis::Async::Sidekiq.setup(Travis.config.redis.url, Travis.config.sidekiq)

Travis::Async.enabled = true
Travis::Amqp.config = Travis.config.amqp
GH::DefaultStack.options[:ssl] = Travis.config.ssl
Travis::Exceptions::Reporter.start
Travis::Notification.setup
Travis::Addons.register

Travis.config.update_periodically
Travis::Memory.new(:hub).report_periodically if Travis.env == 'production'
Travis::Memory.new(:hub).report_periodically if Travis.env == 'production'
NewRelic.start if File.exists?('config/newrelic.yml')

Travis::Exceptions::Reporter.start
Travis::Notification.setup
Travis::Addons.register
# do we still need these in hub?
# Travis::Mailer.setup
# GH::DefaultStack.options[:ssl] = Travis.config.ssl
end

Travis::Database.connect
Travis::Mailer.setup
Travis::Async::Sidekiq.setup(Travis.config.redis.url, Travis.config.sidekiq)
def run
enqueue_jobs
Queue.subscribe(&method(:handle))
end

NewRelic.start if File.exists?('config/newrelic.yml')
end
private

def prune_workers
run_periodically(Travis.config.workers.prune.interval, &::Worker.method(:prune))
def handle(event, payload)
ActiveRecord::Base.cache do
Travis.run_service(:update_job, event: event.to_s.split(':').last, data: payload)
end
end

def enqueue_jobs
run_periodically(Travis.config.queue.interval) do
Travis.run_service(:enqueue_jobs) unless Travis::Features.feature_active?(:travis_enqueue)
end
def enqueue_jobs
run_periodically(Travis.config.queue.interval) do
Travis.run_service(:enqueue_jobs) unless Travis::Features.feature_active?(:travis_enqueue)
end
end

# def cleanup_jobs
# run_periodically(Travis.config.jobs.retry.interval, &::Job.method(:cleanup))
# end
end
# class Instrument < Travis::Notification::Instrument
# def update_completed
# publish(msg: %(for #<Job id="#{target.payload['id']}">), event: target.event, payload: target.payload)
# end
# end
# Instrument.attach_to(self)
end
end
30 changes: 0 additions & 30 deletions lib/travis/hub/cli.rb

This file was deleted.

52 changes: 0 additions & 52 deletions lib/travis/hub/handler.rb

This file was deleted.

46 changes: 0 additions & 46 deletions lib/travis/hub/handler/job.rb

This file was deleted.

25 changes: 0 additions & 25 deletions lib/travis/hub/instrument.rb

This file was deleted.

22 changes: 0 additions & 22 deletions lib/travis/hub/metrics.rb

This file was deleted.

0 comments on commit abe8cea

Please sign in to comment.