Sha256: b08885798014b96e508dad8f65afcabaaa4e4e88da08f2e5eb8a045966737f87

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

require 'digest/sha1'

module Kirk
  # This class extends a native Java class
  class Server::HotDeployable < Native::HotDeployableApplication

    def initialize(config)
      super(config)
      deploy
    end

    def key
      gemfile  = "#{application_path}/Gemfile"
      lockfile = "#{application_path}/Gemfile.lock"

      if File.exist?(gemfile) && File.exist?(lockfile)
        str = File.read(gemfile) + File.read(lockfile)
        Digest::SHA1.hexdigest(str)
      end
    end

    def add_watcher(watcher)
      add_life_cycle_listener(watcher)
    end

    def application_path
      config.application_path
    end

    def rackup_path
      config.rackup
    end

    def last_modified
      mtimes = config.watch.map do |path|
        path = File.expand_path(path, application_path)
        File.exist?(path) ? File.mtime(path).to_i : 0
      end

      mtimes.max
    end

    def deploy(deploy = nil)
      deploy ||= build_deploy

      if deploy
        deploy.prepare
        super(deploy)
        true
      end
    rescue Exception => e
      Kirk.logger.warning "Deploying `#{application_path}` failed: #{e.message}"
      nil
    end

    def build_deploy
      super
    rescue Exception => e
      Kirk.logger.warning "Warming up `#{application_path}` failed: #{e.message}"
      nil
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kirk-0.2.0.beta.7-java lib/kirk/server/hot_deployable.rb
kirk-0.2.0.beta.6-java lib/kirk/server/hot_deployable.rb
kirk-0.2.0.beta.5-java lib/kirk/server/hot_deployable.rb
kirk-0.2.0.beta.4-java lib/kirk/server/hot_deployable.rb
kirk-0.2.0.beta.3-java lib/kirk/server/hot_deployable.rb
kirk-0.2.0.beta.2-java lib/kirk/server/hot_deployable.rb
kirk-0.2.0.beta.1-java lib/kirk/server/hot_deployable.rb