Class: Vagrant::Notify::Action::StopServer
- Inherits:
-
Object
- Object
- Vagrant::Notify::Action::StopServer
- Defined in:
- lib/vagrant-notify/action/stop_server.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ StopServer
constructor
A new instance of StopServer.
Constructor Details
#initialize(app, env) ⇒ StopServer
Returns a new instance of StopServer.
5 6 7 |
# File 'lib/vagrant-notify/action/stop_server.rb', line 5 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant-notify/action/stop_server.rb', line 9 def call(env) return if env[:machine].config.notify.enable == false 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 env[:notify_data][:bind_ip] = nil unless env[:notify_restart] end |