Class: Stable::Services::AppRestarter
- Inherits:
-
Object
- Object
- Stable::Services::AppRestarter
- Defined in:
- lib/stable/services/app_restarter.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(name) ⇒ AppRestarter
constructor
A new instance of AppRestarter.
Constructor Details
#initialize(name) ⇒ AppRestarter
Returns a new instance of AppRestarter.
6 7 8 |
# File 'lib/stable/services/app_restarter.rb', line 6 def initialize(name) @name = name end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/stable/services/app_restarter.rb', line 10 def call app = Services::AppRegistry.find(@name) unless app puts("No app found with name #{@name}") return end # Stop if running if app[:pid] begin Process.kill('TERM', app[:pid].to_i) rescue Errno::ESRCH # already dead end AppRegistry.update(@name, started_at: nil, pid: nil) puts "✔ #{@name} stopped" end Services::AppStarter.new(@name).call end |