Sha256: bd41737f14971044a9b703b3960de51e9fc4817db901da4e5f61eee8e38b68b7

Contents?: true

Size: 892 Bytes

Versions: 1

Compression:

Stored size: 892 Bytes

Contents

module Vagrant
  module Notify
    module Action
      class StopServer
        def initialize(app, env)
          @app = app
        end

        def call(env)
          if env[:machine].state.id == :running
            env[:machine].communicate.sudo('rm /usr/bin/notify-send; exit 0')
            env[:machine].communicate.sudo('mv /usr/bin/{notify-send.bkp,notify-send}; exit 0')
          end

          @app.call env

          pid = env[:notify_data][:pid]

          begin
            Process.kill('KILL', pid.to_i)
            env[:machine].ui.success("Stopped vagrant-notify-server pid: #{pid}")
          rescue Errno::ESRCH
            nil
          rescue
            env[:machine].ui.error("Failed to stop vagrant-notify-server pid: #{pid}")
          end

          env[:notify_data][:pid]  = nil
          env[:notify_data][:port] = nil
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-notify-0.5.0 lib/vagrant-notify/action/stop_server.rb