Skip to content

Instantly share code, notes, and snippets.

@Chocksy
Chocksy / kill_sidekiq_job.rb
Last active July 16, 2024 16:24
Kill sidekiq jobs by process id for busy jobs and by jid for other sets.
# FOR BUSY JOBS
# take the process_id from the /busy page in sidekiq and kill the longest running one.
workers = Sidekiq::Workers.new
long_process_id = 'integration.3:4:71111aaa111' # Eg: 'integration.3:4:71d1d7f4ef5a'
workers.each do |process_id, thread_id, work|
process = Sidekiq::Process.new('identity' => process_id)
process.stop! if process_id == long_process_id
end
# FOR SCHEDULED JOBS
@sj26
sj26 / boot.rb
Last active September 27, 2018 09:59
Use dotenv with unicorn (put in config/boot.rb, thanks @keithpitt)
require "dotenv"
dotenv_root = File.expand_path("../../", __FILE__)
dotenv_env = ENV.fetch("RAILS_ENV", ENV.fetch("RACK_ENV", "development"))
dotenv_files = ["#{dotenv_root}/.env.#{dotenv_env}", "#{dotenv_root}/.env"]
if ENV.include? "DOTENV_LOADED"
ENV["DOTENV_LOADED"].split(":").each do |key|
ENV.delete(key)
end