Sha256: 7e154c8f71a55d7e08eb92c98fd17b7350087c044e1b52089b4495892cd4d474

Contents?: true

Size: 1.42 KB

Versions: 9

Compression:

Stored size: 1.42 KB

Contents

# Don't change this file!
# Configure your daemon in config/environment.rb

DAEMON_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?( DAEMON_ROOT )

module DaemonKit
  class << self
    def boot!
      unless booted?
        pick_boot.run
      end
    end

    def booted?
      defined? DaemonKit::Initializer
    end

    def pick_boot
      (vendor_kit? ? VendorBoot : GemBoot).new
    end

    def vendor_kit?
      File.exists?( "#{DAEMON_ROOT}/vendor/daemon_kit" )
    end
  end

  class Boot
    def run
      load_initializer
      DaemonKit::Initializer.run
    end
  end

  class VendorBoot < Boot
    def load_initializer
      require "#{DAEMON_ROOT}/vendor/daemon_kit/lib/daemon_kit/initializer"
    end
  end
  
  class GemBoot < Boot
    def load_initializer
      begin
        require 'rubygems'
        gem 'kennethkalmer-daemon-kit'
        require 'daemon_kit/initializer'
      rescue Gem::LoadError
        begin
          gem 'daemon-kit'
          require 'daemon_kit/initializer'
        rescue Gem::LoadError => e
          msg = <<EOF
You are missing the daemon-kit gem. Please install one of the following gems:

* Unstable - sudo gem install kennethkalmer-daemon-kit -s http://gems.github.com/
* Stable   - sudo gem install daemon-kit

NOTE: The 'unstable' gem is loaded first, before falling back to the stable gem!

EOF
          $stderr.puts msg
          exit 1
        end
      end
    end
  end
end

DaemonKit.boot!

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
kennethkalmer-daemon-kit-0.1.3 app_generators/daemon_kit/templates/config/boot.rb
kennethkalmer-daemon-kit-0.1.4 app_generators/daemon_kit/templates/config/boot.rb
kennethkalmer-daemon-kit-0.1.5.1 app_generators/daemon_kit/templates/config/boot.rb
kennethkalmer-daemon-kit-0.1.5 app_generators/daemon_kit/templates/config/boot.rb
kennethkalmer-daemon-kit-0.1.6 app_generators/daemon_kit/templates/config/boot.rb
daemon-kit-0.1.6 app_generators/daemon_kit/templates/config/boot.rb
daemon-kit-0.1.5.1 app_generators/daemon_kit/templates/config/boot.rb
daemon-kit-0.1.3 app_generators/daemon_kit/templates/config/boot.rb
daemon-kit-0.1.7 app_generators/daemon_kit/templates/config/boot.rb