Sha256: 9341703f5f4ae82b92b95409d3ef6214a2aaed683bfd467e670b658651438f8c

Contents?: true

Size: 1.47 KB

Versions: 6

Compression:

Stored size: 1.47 KB

Contents

Eye::Cli.class_eval do
  private

  def loader_path
    filename = File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. .. bin eye-patch-loader]))
    File.exists?(filename) ? filename : nil
  end
end

Eye::System.class_eval do
  class << self
    alias_method :daemonize_without_hook, :daemonize
    alias_method :exec_without_hook, :exec

    def daemonize(*args)
      Eye::Control.invoke_spawn_callback
      daemonize_without_hook(*args)
    end

    def exec(*args)
      Eye::Control.invoke_spawn_callback
      exec_without_hook(*args)
    end

    private

    def spawn_options(config = {})
      options = {
        pgroup: true,
        chdir: config[:working_dir] || '/',
        close_others: !config[:preserve_fds] }

      options[:out]   = [config[:stdout], 'a'] if config[:stdout]
      options[:err]   = [config[:stderr], 'a'] if config[:stderr]
      options[:in]    = config[:stdin] if config[:stdin]
      options[:umask] = config[:umask] if config[:umask]

      if Eye::Local.root?
        options[:uid] = Etc.getpwnam(config[:uid]).uid if config[:uid]
        options[:gid] = Etc.getpwnam(config[:gid]).gid if config[:gid]
      end

      options
    end
  end
end

Eye::Controller.class_eval do

  def invoke_spawn_callback
    debug "Attempting before_spawn hook"
    if respond_to?(:before_spawn)
      debug "Invoking before_spawn hook"
      before_spawn
    end
  end

  private

  def parse_config(filename)
    Eye::Patch.parse(filename)
  end
end

Eye::Control

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
eye-patch-0.1.5 lib/eye/patch/overrides.rb
eye-patch-0.1.4 lib/eye/patch/overrides.rb
eye-patch-0.1.3 lib/eye/patch/overrides.rb
eye-patch-0.1.2 lib/eye/patch/overrides.rb
eye-patch-0.1.1 lib/eye/patch/overrides.rb
eye-patch-0.1.0 lib/eye/patch/overrides.rb