Sha256: bbda32a2acacf1a330b07d6d082902bdbb302656a288f3e4c07f872dfaacfd0f

Contents?: true

Size: 905 Bytes

Versions: 3

Compression:

Stored size: 905 Bytes

Contents

require_relative 'windows/process_info'

module Vagrant
  module Notify
    module Action
      class ServerIsRunning
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant::notify::action::prepare_data_dir")
        end

        def call(env)
          env[:result] = valid_process?(env[:notify_data][:pid])

          # Call the next if we have one (but we shouldn't, since this
          # middleware is built to run with the Call-type middlewares)
          @app.call env
        end

        private

        def valid_process?(pid)
          if RUBY_PLATFORM =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
            Vagrant::Notify::Action::Windows::ProcessInfo.queryProcess(pid) if pid
          else
            Process.getpgid(pid.to_i) if pid
          end
          rescue Errno::ESRCH
            false
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-notify-0.5.2 lib/vagrant-notify/action/server_is_running.rb
vagrant-notify-0.5.1 lib/vagrant-notify/action/server_is_running.rb
vagrant-notify-0.5.0 lib/vagrant-notify/action/server_is_running.rb