Sha256: eb9cd9affaef0d71dfe1fd0c4f0ccbcde5ec5831aa9d694609a07c8b92134b3b
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
require 'rackjour' module Rackjour class Worker @@started = false def initialize unless @@started @@started = true DNSSD.register('rackjour_worker', '_druby._tcp', nil, 9199) DRb.start_service("druby://0.0.0.0:#{WORKER_PORT}", Worker.new) DRb.thread.join end end def add_app(app) @apps ||= {} log "job: #{@version} #{app}" rack_app = app.new(lambda { |env| env }) @apps[app] = rack_app end def add_terminator(app) log "job: #{@version} #{app} (terminator)" @apps[app] = app.new end def setup(version, tar, config) @version = version @deployed = false @config = config @base_dir = Dir.mktmpdir log "installing to #{@base_dir}" Dir.chdir @base_dir do File.open(File.join(@base_dir, 'app.tgz'), 'w') do |file| file << tar end `tar zxf app.tgz` end load_deps end def call(app, env) log app @apps[app].call(env) end def load_deps Dir.chdir(@base_dir) do File.readlines(@config).each do |line| if line =~ /require ['"](.+)['"]$/ req = $1 req = File.join(@base_dir, req) if req =~ /environment/ require req end end end end def log(str) puts "worker: #{str}" end end end if __FILE__ == $0 Rackjour::Worker.new end
Version data entries
2 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rackjour-0.1.8 | lib/rackjour/worker.rb |
rackjour-0.1.8 | vendor/gems/gems/rackjour-0.1.5/lib/rackjour/worker.rb |