Class: LogicalConstruct::Target::FlightDeck::ResolutionServerTask

Inherits:
Mattock::Rake::Task
  • Object
show all
Defined in:
lib/logical-construct/target/flight-deck.rb

Direct Known Subclasses

DaemonizedResolutionServerTask

Instance Method Summary collapse

Instance Method Details

#action(args) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/logical-construct/target/flight-deck.rb', line 40

def action(args)
  require 'roadforest/server'
  require 'logical-construct/target/resolution-server'
  require 'webrick/accesslog'
  services = ResolutionServer::ServicesHost.new

  services.plan_records.directories.delivered = delivered.absolute_path
  services.plan_records.directories.current = current.absolute_path
  services.plan_records.directories.stored = stored.absolute_path

  logfile = File::open(log_file.absolute_path, "a")
  logfile.sync = true

  application = ResolutionServer::Application.new("http://localhost:#{port}", services)
  application.configure do |config|
    config.port = port
    config.adapter_options = {
      :Logger => WEBrick::Log.new(logfile),
      :AccessLog => [
        [logfile, WEBrick::AccessLog::COMMON_LOG_FORMAT ],
        [logfile, WEBrick::AccessLog::REFERER_LOG_FORMAT ]
    ]
    }
  end
  application.run
end

#needed?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/logical-construct/target/flight-deck.rb', line 25

def needed?
  if ::Rake.application.options.trace
    ::Rake.application.trace("Checking to see if a service is running at #{port}")
    if TCPPortOpenCheck.new(port).open?
      ::Rake.application.trace("  ...yes - task not needed")
      return false
    else
      ::Rake.application.trace("  ...no - task needed")
      return true
    end
  else
    !TCPPortOpenCheck.new(port).open?
  end
end

#resolve_configurationObject



20
21
22
23
# File 'lib/logical-construct/target/flight-deck.rb', line 20

def resolve_configuration
  resolve_paths
  super
end