This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Some | |
include Mongoid::Document | |
field :some_field | |
has_and_belongs_to_many :habtms | |
def sorted_habtms | |
hbtm_ids.each_with_object([]){|id,a| h = habtms.find(id); a << h} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: unicorn | |
# Required-Start: $local_fs $remote_fs mysql | |
# Required-Stop: $local_fs $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: unicorn initscript | |
# Description: Unicorn is an HTTP server for Rack application | |
### END INIT INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# put this somewhere in your project, ie: /lib | |
# use: | |
# crontab -e | |
# */30 * * * * /usr/bin/ruby /your_rails_project/lib/this_file.rb | |
# that will insert this job into your delayed_job queue every 30 minutes. | |
require 'rubygems' | |
require 'mysql' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My pimped out unicorn config, with incremental killof | |
# and all the latest capistrano & bundler-proofing | |
# @jamiew :: http://github.com/jamiew | |
application = "000000book.com" | |
environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'production' | |
app_path = "/srv/#{application}" | |
bundle_path = "#{app_path}/shared/bundle" | |
timeout 30 |