resque-mongo 1.8.1 → 1.9.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'logger'
3
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
4
- require 'app'
5
- require 'resque/server'
6
-
7
- use Rack::ShowExceptions
8
-
9
- # Set the AUTH env variable to your basic auth password to protect Resque.
10
- AUTH_PASSWORD = ENV['AUTH']
11
- if AUTH_PASSWORD
12
- Resque::Server.use Rack::Auth::Basic do |username, password|
13
- password == AUTH_PASSWORD
14
- end
15
- end
16
-
17
- run Rack::URLMap.new \
18
- "/" => Demo::App.new,
19
- "/resque" => Resque::Server.new
@@ -1,22 +0,0 @@
1
- require 'resque'
2
-
3
- module Demo
4
- module Job
5
- @queue = :default
6
-
7
- def self.perform(params)
8
- sleep 1
9
- puts "Processed a job!"
10
- end
11
- end
12
-
13
- module FailingJob
14
- @queue = :failing
15
-
16
- def self.perform(params)
17
- sleep 1
18
- raise 'not processable!'
19
- puts "Processed a job!"
20
- end
21
- end
22
- end
@@ -1,53 +0,0 @@
1
- rails_env = ENV['RAILS_ENV'] || "production"
2
- rails_root = ENV['RAILS_ROOT'] || "/data/github/current"
3
- num_workers = rails_env == 'production' ? 5 : 2
4
-
5
- num_workers.times do |num|
6
- God.watch do |w|
7
- w.name = "resque-#{num}"
8
- w.group = 'resque'
9
- w.interval = 30.seconds
10
- w.env = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env}
11
- w.start = "/usr/bin/rake -f #{rails_root}/Rakefile environment resque:work"
12
-
13
- w.uid = 'git'
14
- w.gid = 'git'
15
-
16
- # retart if memory gets too high
17
- w.transition(:up, :restart) do |on|
18
- on.condition(:memory_usage) do |c|
19
- c.above = 350.megabytes
20
- c.times = 2
21
- end
22
- end
23
-
24
- # determine the state on startup
25
- w.transition(:init, { true => :up, false => :start }) do |on|
26
- on.condition(:process_running) do |c|
27
- c.running = true
28
- end
29
- end
30
-
31
- # determine when process has finished starting
32
- w.transition([:start, :restart], :up) do |on|
33
- on.condition(:process_running) do |c|
34
- c.running = true
35
- c.interval = 5.seconds
36
- end
37
-
38
- # failsafe
39
- on.condition(:tries) do |c|
40
- c.times = 5
41
- c.transition = :start
42
- c.interval = 5.seconds
43
- end
44
- end
45
-
46
- # start if process is not running
47
- w.transition(:up, :start) do |on|
48
- on.condition(:process_running) do |c|
49
- c.running = false
50
- end
51
- end
52
- end
53
- end
@@ -1,26 +0,0 @@
1
- # This will ride alongside god and kill any rogue stale worker
2
- # processes. Their sacrifice is for the greater good.
3
-
4
- WORKER_TIMEOUT = 60 * 10 # 10 minutes
5
-
6
- Thread.new do
7
- loop do
8
- begin
9
- `ps -e -o pid,command | grep [r]esque`.split("\n").each do |line|
10
- parts = line.split(' ')
11
- next if parts[-2] != "at"
12
- started = parts[-1].to_i
13
- elapsed = Time.now - Time.at(started)
14
-
15
- if elapsed >= WORKER_TIMEOUT
16
- ::Process.kill('USR1', parts[0].to_i)
17
- end
18
- end
19
- rescue
20
- # don't die because of stupid exceptions
21
- nil
22
- end
23
-
24
- sleep 30
25
- end
26
- end
@@ -1,11 +0,0 @@
1
- # DelayedJob wants you to create instances. No problem.
2
-
3
- class Archive < Struct.new(:repo_id, :branch)
4
- def self.perform(*args)
5
- new(*args).perform
6
- end
7
-
8
- def perform
9
- # do work!
10
- end
11
- end
@@ -1,6 +0,0 @@
1
- check process resque_worker_QUEUE
2
- with pidfile /data/APP_NAME/current/tmp/pids/resque_worker_QUEUE.pid
3
- start program = "/bin/sh -c 'cd /data/APP_NAME/current; RAILS_ENV=production QUEUE=queue_name VERBOSE=1 nohup rake resque:work& &> log/resque_worker_QUEUE.log && echo $! > tmp/pids/resque_worker_QUEUE.pid'" as uid deploy and gid deploy
4
- stop program = "/bin/sh -c 'cd /data/APP_NAME/current && kill -s QUIT `cat tmp/pids/resque_worker_QUEUE.pid` && rm -f tmp/pids/resque_worker_QUEUE.pid; exit 0;'"
5
- if totalmem is greater than 300 MB for 10 cycles then restart # eating up memory?
6
- group resque_workers
@@ -1,30 +0,0 @@
1
- # This is a simple Resque job.
2
- class Archive
3
- @queue = :file_serve
4
-
5
- def self.perform(repo_id, branch = 'master')
6
- repo = Repository.find(repo_id)
7
- repo.create_archive(branch)
8
- end
9
- end
10
-
11
- # This is in our app code
12
- class Repository < Model
13
- # ... stuff ...
14
-
15
- def async_create_archive(branch)
16
- Resque.enqueue(Archive, self.id, branch)
17
- end
18
-
19
- # ... more stuff ...
20
- end
21
-
22
- # Calling this code:
23
- repo = Repository.find(22)
24
- repo.async_create_archive('homebrew')
25
-
26
- # Will return immediately and create a Resque job which is later
27
- # processed.
28
-
29
- # Essentially, this code is run by the worker when processing:
30
- Archive.perform(22, 'homebrew')
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'resque'