mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Clean up examples
This commit is contained in:
parent
b4d124dbe2
commit
da0bdd85df
5 changed files with 0 additions and 111 deletions
|
@ -1,44 +0,0 @@
|
|||
# Sidekiq defers scheduling to other, better suited gems.
|
||||
# If you want to run a job regularly, here's an example
|
||||
# of using the 'clockwork' gem to push jobs to Sidekiq
|
||||
# regularly.
|
||||
|
||||
# require boot & environment for a Rails app
|
||||
# require_relative "../config/boot"
|
||||
# require_relative "../config/environment"
|
||||
require "clockwork"
|
||||
|
||||
class MyWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(count)
|
||||
puts "Job ##{count}: Late night, so tired..."
|
||||
end
|
||||
|
||||
def self.late_night_work
|
||||
10.times do |x|
|
||||
perform_async(x)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class HourlyWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform
|
||||
cleanup_database
|
||||
format_hard_drive
|
||||
end
|
||||
end
|
||||
|
||||
module Clockwork
|
||||
# Kick off a bunch of jobs early in the morning
|
||||
every 1.day, 'my_worker.late_night_work', :at => '4:30 am' do
|
||||
MyWorker.late_night_work
|
||||
end
|
||||
|
||||
every 1.hour do
|
||||
HourlyWorker.perform_async
|
||||
end
|
||||
end
|
||||
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
require 'sidekiq'
|
||||
|
||||
redis = { :namespace => 'leak' }
|
||||
Sidekiq.configure_client { |config| config.redis = redis }
|
||||
Sidekiq.configure_server { |config| config.redis = redis }
|
||||
|
||||
$c = 0
|
||||
$max = 10_000
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
check process sidekiq_myapp
|
||||
with pidfile /path/to/sidekiq.pid
|
||||
start program = "bundle exec sidekiq -C /path/to/sidekiq_conf.yml -P /path/to/sidekiq.pid" with timeout 30 seconds
|
||||
stop program = "kill -s TERM `cat /path/to/sidekiq.pid`" with timeout 30 seconds
|
||||
if totalmem is greater than 500 MB for 2 cycles then restart # VM bloat is common in Rails apps
|
||||
group myapp_sidekiq
|
|
@ -1,15 +1,5 @@
|
|||
require 'sidekiq'
|
||||
|
||||
# If your client is single-threaded, we just need a single connection in our Redis connection pool
|
||||
Sidekiq.configure_client do |config|
|
||||
config.redis = { :namespace => 'x', :size => 1 }
|
||||
end
|
||||
|
||||
# Sidekiq server is multi-threaded so our Redis connection pool size defaults to concurrency (-c)
|
||||
Sidekiq.configure_server do |config|
|
||||
config.redis = { :namespace => 'x' }
|
||||
end
|
||||
|
||||
# Start up sidekiq via
|
||||
# ./bin/sidekiq -r ./examples/por.rb
|
||||
# and then you can open up an IRB session like so:
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
# Sidekiq defers scheduling cron-like tasks to other, better suited gems.
|
||||
# If you want to run a job regularly, here's an example
|
||||
# of using the 'whenever' gem to push jobs to Sidekiq
|
||||
# regularly.
|
||||
|
||||
class MyWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(count)
|
||||
puts "Job ##{count}: Late night, so tired..."
|
||||
end
|
||||
|
||||
def self.late_night_work
|
||||
10.times do |x|
|
||||
perform_async(x)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Kick off a bunch of jobs early in the morning
|
||||
every 1.day, :at => '4:30 am' do
|
||||
runner "MyWorker.late_night_work"
|
||||
end
|
||||
|
||||
|
||||
class HourlyWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform
|
||||
cleanup_database
|
||||
format_hard_drive
|
||||
end
|
||||
end
|
||||
|
||||
every :hour do # Many shortcuts available: :hour, :day, :month, :year, :reboot
|
||||
runner "HourlyWorker.perform_async"
|
||||
end
|
||||
|
||||
# Using the runner command loads an extra rails instance
|
||||
# If you want to avoid this you can use the sidekiq-client-cli gem which is a commmand line sidekiq client
|
||||
# Define a new job_type
|
||||
job_type :sidekiq, "cd :path && RAILS_ENV=:environment bundle exec sidekiq-client :task :output"
|
||||
|
||||
# Add the worker to the queue directly
|
||||
every :hour do
|
||||
sidekiq "push HourlyWorker"
|
||||
end
|
Loading…
Add table
Reference in a new issue