Class: Rpush::Daemon::Synchronizer
Constant Summary
collapse
- APP_ATTRIBUTES_TO_CHECK =
[:certificate, :environment, :auth_key, :client_id, :client_secret].freeze
Class Method Summary
collapse
Methods included from Loggable
log_debug, log_error, log_info, log_warn
pluralize
Class Method Details
.attribute_changed?(app, attr) ⇒ Boolean
52
53
54
55
56
57
58
59
|
# File 'lib/rpush/daemon/synchronizer.rb', line 52
def self.attribute_changed?(app, attr)
if app.respond_to?(attr)
old_app = AppRunner.app_with_id(app.id)
app.send(attr) != old_app.send(attr)
else
false
end
end
|
.changed_attributes(app) ⇒ Object
48
49
50
|
# File 'lib/rpush/daemon/synchronizer.rb', line 48
def self.changed_attributes(app)
APP_ATTRIBUTES_TO_CHECK.select { |attr| attribute_changed?(app, attr) }
end
|
.sync_app(app) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/rpush/daemon/synchronizer.rb', line 18
def self.sync_app(app)
if !AppRunner.app_running?(app)
AppRunner.start_app(app)
elsif (changed_attrs = changed_attributes(app)).count > 0
changed_attrs_str = changed_attrs.map(&:to_s).join(", ")
log_info("[#{app.name}] #{changed_attrs_str} changed, restarting...")
AppRunner.stop_app(app.id)
AppRunner.start_app(app)
else
sync_dispatcher_count(app)
end
end
|
.sync_dispatcher_count(app) ⇒ Object