Class: Stable::Services::AppRestarter
- Inherits:
-
Object
- Object
- Stable::Services::AppRestarter
- Defined in:
- lib/stable/services/app_restarter.rb
Overview
Service for restarting Rails applications
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.
7 8 9 |
# File 'lib/stable/services/app_restarter.rb', line 7 def initialize(name) @name = name end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/stable/services/app_restarter.rb', line 11 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 |