pg_queue 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,6 +18,12 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install pg_queue
20
20
 
21
+ Now you need to create the table where jobs will be stored:
22
+
23
+ $ rake environment pg_queue:create_table
24
+
25
+ Run `rake -T pg_queue` for more tasks
26
+
21
27
  ## Usage
22
28
 
23
29
  ### Rails
@@ -26,7 +32,7 @@ Create an initializer with the configuration
26
32
 
27
33
  PgQueue.connection = ActiveRecord::Base.connection.raw_connection
28
34
  PgQueue.logger = Rails.logger
29
- PgQueue.interval = 3 # the number of seconds you want the worker wait after process the job
35
+ PgQueue.interval = 3 # the number of seconds you want the worker wait after process a job
30
36
 
31
37
  Add this line in the Rakefile
32
38
 
@@ -47,3 +53,17 @@ That's it! You're now able to enqueue your jobs. To do that, just call
47
53
  3. Commit your changes (`git commit -am 'Added some feature'`)
48
54
  4. Push to the branch (`git push origin my-new-feature`)
49
55
  5. Create new Pull Request
56
+
57
+ ## Maintainer
58
+
59
+ Rafael Souza [(rafaelss.com)](http://rafaelss.com/)
60
+
61
+ ## License
62
+
63
+ (The MIT License)
64
+
65
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66
+
67
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
68
+
69
+ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,6 +1,5 @@
1
1
  namespace :pg_queue do
2
- desc "Start worker"
3
- task :work do
2
+ def start_worker
4
3
  worker = PgQueue::Worker.new
5
4
 
6
5
  ["INT", "TERM"].each do |signal|
@@ -9,9 +8,16 @@ namespace :pg_queue do
9
8
  end
10
9
  end
11
10
 
11
+ yield
12
+
12
13
  worker.start
13
14
  end
14
15
 
16
+ desc "Start worker"
17
+ task :work do |args|
18
+ start_worker
19
+ end
20
+
15
21
  desc "Drop jobs table"
16
22
  task :drop_table do
17
23
  PgQueue.connection.exec("DROP TABLE IF EXISTS pg_queue_jobs")
@@ -21,4 +27,25 @@ namespace :pg_queue do
21
27
  task :create_table => :drop_table do
22
28
  PgQueue.connection.exec("CREATE TABLE pg_queue_jobs (id SERIAL, class_name VARCHAR, args TEXT)")
23
29
  end
30
+
31
+ namespace :work do
32
+ desc "Start worker and put it in background"
33
+ task :start do
34
+ start_worker do
35
+ Process.daemon(true)
36
+
37
+ pid_path = File.join(File.expand_path("."), "tmp/pids/pg_queue.pid")
38
+ File.open(pid_path, "w") do |f|
39
+ f.write(Process.pid)
40
+ end
41
+ end
42
+ end
43
+
44
+ desc "Stop worker"
45
+ task :stop do
46
+ pid_path = File.join(File.expand_path("."), "tmp/pids/pg_queue.pid")
47
+ Process.kill("TERM", File.read(pid_path).to_i)
48
+ File.unlink(pid_path)
49
+ end
50
+ end
24
51
  end
@@ -1,3 +1,3 @@
1
1
  module PgQueue
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pg
16
- requirement: &70201794377100 !ruby/object:Gem::Requirement
16
+ requirement: &70281738446580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.13.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70201794377100
24
+ version_requirements: *70281738446580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: multi_json
27
- requirement: &70201794376540 !ruby/object:Gem::Requirement
27
+ requirement: &70281738446020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70201794376540
35
+ version_requirements: *70281738446020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70201794375980 !ruby/object:Gem::Requirement
38
+ requirement: &70281738445480 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.8.7
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70201794375980
46
+ version_requirements: *70281738445480
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70201794375500 !ruby/object:Gem::Requirement
49
+ requirement: &70281738445000 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 2.8.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70201794375500
57
+ version_requirements: *70281738445000
58
58
  description: Some experimentations with LISTEN/NOTIFY for background jobs
59
59
  email:
60
60
  - me@rafaelss.com