delayed_job_active_record_threaded 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4a6bd62a6a5e97dd63f75c7d18de220d1494304
4
- data.tar.gz: 308d9aed19966440ae784559d7651b07675884a4
3
+ metadata.gz: 864851553076265c22eb06a51fbc06894bbaa3a5
4
+ data.tar.gz: 5cbfba03389e2369e1824e65abc7746dacbaad84
5
5
  SHA512:
6
- metadata.gz: a2798cb2e8f68d171724c34d8114ec2e284c797191463804a17a3e1230a8c04c69c4727ed85dceaa68acf61b471984c8ba3f262008519d32b8f9bf1d56326eac
7
- data.tar.gz: 51afdb426a5b47f0b0d6aa978ef3899a6b0a6a24133a98fefcc2f771a24e8e6a73b58185e2e3b19008a2d06043ac3359a10173a936565fe2d5e2c725db7afc0f
6
+ metadata.gz: 72e07e672c5ae64722d932a5a418fddbff0d2d40eadfc134bcd6a3f20eb9912722db28abe9b1dee17af433adcc9b8edda2fadadac91dea6621736a8de9e3dfc4
7
+ data.tar.gz: c00333cf69cffa44bf5ae44455acfce75d092607b6ee740058a509d31a27ab9b65e2c6ca9c3ecff88fa482c39d9eeb4d8205145d8cc67776edd0510881dde601
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## v0.0.2
2
+
3
+ * fixed issues with tasks
4
+
5
+ ## v0.0.1
6
+
7
+ * initial release
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
- # DelayedJobActiveRecordThreaded
1
+ # DelayedJobActiveRecordThreaded [![Build Status](https://travis-ci.org/zxiest/delayed_job_active_record_threaded.png)](http://travis-ci.org/zxiest/delayed_job_active_record_threaded)
2
2
 
3
- TODO: Write a gem description
3
+ DelayedJob allows you to execute long-running jobs at a later time. For more information on how to create and delay a job, follow https://github.com/collectiveidea/delayed_job
4
+
5
+ This gem processes your delayed jobs with a single threaded process (instead of multiple processes).
6
+ This helps avoid database deadlocks and saves computing resources.
4
7
 
5
8
  ## Installation
6
9
 
@@ -16,9 +19,58 @@ Or install it yourself as:
16
19
 
17
20
  $ gem install delayed_job_active_record_threaded
18
21
 
22
+
23
+ ## Setup
24
+ Make sure to pick the correct setup method prior to proceeding:
25
+
26
+ ### Fresh setup
27
+ Follow this setup method if you do have not been using delayed_job_active_record in your project and do not have a "delayed_jobs" table created:
28
+
29
+ $ rails generate delayed_job:active_record
30
+ $ rake db:migrate
31
+
32
+ ### Upgrading from delayed_job_active_record
33
+
34
+ If you were previously using delayed_job_active_record, follow the steps below:
35
+
36
+ $ rails generate delayed_job:upgrade
37
+ $ rake db:migrate
38
+
39
+ This will add columns to your delayed_jobs table.
40
+
19
41
  ## Usage
20
42
 
21
- TODO: Write usage instructions here
43
+ For information on how to create delayed_jobs and enqueue them, follow https://github.com/collectiveidea/delayed_job
44
+
45
+ In order to start the threaded process this gem provides, use the following:
46
+
47
+ ### Defaults
48
+
49
+ $ bundle exec rake delayed_job:start
50
+ or
51
+ $ bundle exec rake dj:start
52
+
53
+ ### With Options
54
+
55
+ The default task processes items belonging to all the queues. This is, most of times, not desirable as tasks with higher priority in a given queue take precedence over tasks in another queue.
56
+
57
+ You can have multiple queues processed simultaneously, each with its own options.
58
+ In the example below, we assume you have an "ebooks" and an "albums" queues.
59
+
60
+ The command below will process the queues ebooks and albums simultaneously
61
+ $ bundle exec rake "dj:start[ebooks&albums]"
62
+
63
+ $ bundle exec rake "dj:start[ebooks[workers_number]=16&ebooks[worker_timeout]=60&albums[workers_number]=32&albums[worker_timeout]=120]"
64
+
65
+ The expression "ebooks[workers_number]=16&ebooks[worker_timeout]=60" is a parsed similarly to a URL's query string and would be converted into the following hash:
66
+
67
+ {"ebooks"=>{"workers_number"=>"16", "worker_timeout"=>"60"}, "albums"=>{"workers_number"=>"32", "worker_timeout"=>"120"}}
68
+
69
+ The rake task above will start a process in the background and process two queues, "ebooks" with 16 working threads and times out after 60 seconds and "albums" with 32 working threads and times out after 120 seconds.
70
+
71
+ Default options:
72
+ workers_number: 16
73
+ worker_timeout: 60
22
74
 
23
75
  ## Contributing
24
76
 
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency 'activerecord', ['>= 3.0', '< 4.1']
26
26
  spec.add_dependency 'delayed_job', ['>= 3.0', '< 4.1']
27
27
  spec.add_dependency 'celluloid', ['>=0.14.1']
28
- spec.version = "0.0.1"
28
+ spec.version = "0.0.2"
29
29
  end
data/lib/tasks/dj.rake CHANGED
@@ -2,11 +2,11 @@ require 'rack/utils'
2
2
 
3
3
  namespace :dj do
4
4
  task :run, [:args_expr ] => :environment do |t,args|
5
- Rake::Task["delayed_job:run"].invoke(args[:args_expr].nil? ? args : args[:args_expr])
5
+ Rake::Task["delayed_job:run"].invoke(args[:args_expr])
6
6
  end
7
7
 
8
8
  task :start, [:args_expr ] => :environment do |t,args|
9
- Rake::Task["delayed_job:start"].invoke(args[:args_expr].nil? ? args : args[:args_expr])
9
+ Rake::Task["delayed_job:start"].invoke(args[:args_expr])
10
10
  end
11
11
 
12
12
  task :stop, [:args_expr ] => :environment do |t,args|
@@ -18,7 +18,7 @@ namespace :dj do
18
18
  end
19
19
 
20
20
  task :print_options, [:args_expr ] => :environment do |t,args|
21
- Rake::Task["delayed_job:print_options"].invoke(args[:args_expr].nil? ? args : args[:args_expr])
21
+ Rake::Task["delayed_job:print_options"].invoke(args[:args_expr])
22
22
  end
23
23
  end
24
24
 
@@ -72,8 +72,8 @@ namespace :delayed_job do
72
72
  task :start, [ :args_expr ] => :environment do |t, args|
73
73
  puts "#{args[:args_expr]}"
74
74
 
75
- cmd = %(if [ -f #{dj_pid} ] && [ -n `cat #{dj_pid}` ] && [ ps -p `cat #{dj_pid}` > /dev/null ]; then sudo kill -9 `cat #{dj_pid}`; fi
76
- (bundle exec rake "delayed_job:run[#{args[:args_expr]}]" >> log/delayed_job.log 2>&1) & (echo $! > tmp/pids/dj.pid)
75
+ cmd = %(if [ -f #{dj_pid} ] && [ -n `cat #{dj_pid}` ] && ps -p `cat #{dj_pid}` > /dev/null; then kill `cat #{dj_pid}`; fi
76
+ (bundle exec rake "delayed_job:run[#{args[:args_expr]}]" >> log/delayed_job.log 2>&1) & (echo $! > #{dj_pid})
77
77
  )
78
78
 
79
79
  puts "executing: #{cmd}"
@@ -83,7 +83,7 @@ namespace :delayed_job do
83
83
  end
84
84
 
85
85
  task :stop => :environment do |t, args|
86
- cmd = %(if [ -f #{dj_pid} ] && [ -n `cat #{dj_pid}` ] && [ ps -p `cat #{dj_pid}` > /dev/null ]; then kill -9 `cat #{dj_pid}`; fi)
86
+ cmd = %(if [ -f #{dj_pid} ] && [ -n `cat #{dj_pid}` ] && ps -p `cat #{dj_pid}` > /dev/null; then kill -9 `cat #{dj_pid}`; fi)
87
87
 
88
88
  # execute cmd
89
89
  %x(#{cmd})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed_job_active_record_threaded
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdo Achkar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-17 00:00:00.000000000 Z
11
+ date: 2013-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,6 +163,7 @@ extra_rdoc_files: []
163
163
  files:
164
164
  - .gitignore
165
165
  - .travis.yml
166
+ - CHANGELOG.md
166
167
  - Gemfile
167
168
  - LICENSE.txt
168
169
  - README.md