Move rpush init/exit logic into Sidekiq initializer
Co-authored-by: nilsding <nilsding@nilsding.org>
This commit is contained in:
parent
10c224b2fe
commit
91d3db4034
|
@ -8,10 +8,6 @@ class PushNotificationWorker
|
||||||
sidekiq_options queue: :push_notification, retry: 0
|
sidekiq_options queue: :push_notification, retry: 0
|
||||||
|
|
||||||
def perform(notification_id)
|
def perform(notification_id)
|
||||||
Rpush.config.push = true
|
|
||||||
Rpush::Daemon.common_init
|
|
||||||
Rpush::Daemon::Synchronizer.sync
|
|
||||||
Rpush::Daemon::AppRunner.enqueue(Rpush::Client::ActiveRecord::Notification.where(id: notification_id))
|
Rpush::Daemon::AppRunner.enqueue(Rpush::Client::ActiveRecord::Notification.where(id: notification_id))
|
||||||
Rpush::Daemon::AppRunner.stop
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,21 @@
|
||||||
|
require "rpush/daemon"
|
||||||
|
require "rpush/daemon/store/active_record"
|
||||||
|
require "rpush/client/active_record"
|
||||||
|
|
||||||
redis_url = ENV.fetch("REDIS_URL") { APP_CONFIG["redis_url"] }
|
redis_url = ENV.fetch("REDIS_URL") { APP_CONFIG["redis_url"] }
|
||||||
|
|
||||||
Sidekiq.configure_server do |config|
|
Sidekiq.configure_server do |config|
|
||||||
config.redis = { url: redis_url }
|
config.redis = { url: redis_url }
|
||||||
|
Rpush.config.push = true
|
||||||
|
Rpush::Daemon.store = Rpush::Daemon::Store::ActiveRecord.new
|
||||||
|
Rpush::Daemon.common_init
|
||||||
|
Rpush::Daemon::Synchronizer.sync
|
||||||
|
|
||||||
|
at_exit do
|
||||||
|
Rpush::Daemon::AppRunner.stop
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Sidekiq.configure_client do |config|
|
Sidekiq.configure_client do |config|
|
||||||
config.redis = { url: redis_url }
|
config.redis = { url: redis_url }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue