#!/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'] 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