Skip to content

Instantly share code, notes, and snippets.

@brenes
Last active August 18, 2021 09:55
Show Gist options
  • Save brenes/054da72418c150f504e7b01928f82abe to your computer and use it in GitHub Desktop.
Save brenes/054da72418c150f504e7b01928f82abe to your computer and use it in GitHub Desktop.
Sidekiq configuration pero host type (AWS TAG)
require 'aws-sdk'
Sidekiq.configure_server do |config|
#.....
ec2 = Aws::EC2::Resource.new(region: 'eu-west-1')
# we build the name if the instance, based on the hostname
i = ec2.instance(Socket.gethostname.gsub(/^[^-]*-/, ''))
# we get its tags and check if it's the desired one
if i.tags.map(&:value).includes('priority-batch')
Sidekiq.options[:queues] = Settings.priority_queues
else
Sidekiq.options[:queues] = Settings.not_priority_queues
end
#.....
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment