Sha256: ee34c5967979870755fbc2a25ed8ea26f05cec3157d75b5e6ee32d1aaf686787

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

#!/usr/bin/env ruby
if !ENV['BACKGROUND'].nil?
  if RUBY_VERSION < "1.9"
    exit if fork
    Process.setsid
    exit if fork
    Dir.chdir "/"
    STDIN.reopen "/dev/null"
    STDOUT.reopen "/dev/null", "a"
    STDERR.reopen "/dev/null", "a"
  else
    Process.daemon
  end
end

require 'drb/drb'
require 'drb/acl'
require 'cucumber-chef'
require 'cucumber/chef/helpers'

tag = Cucumber::Chef.tag("cc-server")
puts("  * #{tag}")
Cucumber::Chef.boot(tag)
$logger = Cucumber::Chef.logger
Dir.chdir(File.join("/home", Cucumber::Chef.lab_user))

class FrontObject
  attr_accessor :containers

  include Cucumber::Chef
  include Cucumber::Chef::Helpers

################################################################################

  def initialize
    logger.info { "DRB=#{DRb.config.inspect}" }

    if ENV['PURGE'] == 'YES'
      Cucumber::Chef.logger.warn { "PURGING CONTAINERS!  Container attributes will be reset!" }
      load_containers
      containers.each do |name, value|
        server_destroy(name)
      end

      File.exists?(Cucumber::Chef.containers_bin) && File.delete(Cucumber::Chef.containers_bin)
      load_containers
    else
      Cucumber::Chef.logger.info { "Allowing existing containers to persist." }
    end
  end

################################################################################

  def shutdown
    logger.fatal { "Shutting down." }
    DRb.stop_service
    exit(0)
  end

################################################################################

  def logger
    $logger
  end

################################################################################

  def ping
    "pong"
  end

################################################################################

end

list = %w(deny all)
ARGV[0] and (list += [ 'allow', ARGV[0] ])
acl = ACL.new(list)

# This will break everything:
# $SAFE = 1

DRb.start_service("druby://:8787", FrontObject.new)
DRb.thread.join

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber-chef-2.1.0.rc.11 bin/cc-server