guard-resque 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -32,6 +32,18 @@ being active.
32
32
  guard 'resque', :environment => 'development' do
33
33
  watch(%r{^app/(.+)\.rb})
34
34
  end
35
+
36
+ ## Options
37
+
38
+ You can customize the resque task via the following options:
39
+
40
+ * `environment`: the rails environment to run the workers in (defaults to `"development"`)
41
+ * `task`: the name of the rake task to use (defaults to `"resque:work"`)
42
+ * `queue`: the resque queue to run (defaults to `"*"`)
43
+ * `verbose`: whether to use verbose logging (defaults to `false`)
44
+ * `trace`: whether to include `--trace` on the rake command (defaults to `false`)
45
+ * `stop_signal`: how to kill the process when restarting (defaults to `KILL`)
46
+
35
47
 
36
48
  ## Development
37
49
 
data/lib/guard/resque.rb CHANGED
@@ -13,28 +13,26 @@ module Guard
13
13
  # :stop_signal e.g. KILL
14
14
  def initialize(watchers = [], options = {})
15
15
  @options = options
16
- @process = nil
17
16
  @pid = nil
18
- @stop_signal = options[:stop_signal] || "TERM"
17
+ @stop_signal = options[:stop_signal] || "KILL"
19
18
  super
20
19
  end
21
20
 
22
21
  def start
23
22
  stop
24
23
  UI.info "Starting up resque..."
25
- @process = IO.popen(cmd)
26
- @pid = @process.pid
24
+ UI.info cmd
25
+ @pid = spawn(cmd)
27
26
  end
28
27
 
29
28
  # Called on Ctrl-C signal (when Guard quits)
30
29
  def stop
31
- if @process
30
+ if @pid
32
31
  UI.info("Stopping resque...")
33
- ::Process.kill(@stop_signal, @process.pid)
32
+ ::Process.kill(@stop_signal, @pid)
34
33
  ::Process.waitpid(@pid) rescue Errno::ESRCH
35
- @process.close
36
34
  @pid = nil
37
- UI.info("Stopped process #{@name}")
35
+ UI.info("Stopped process resque")
38
36
  end
39
37
  end
40
38
 
@@ -42,8 +40,7 @@ module Guard
42
40
  # This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
43
41
  def reload
44
42
  UI.info "Restarting resque..."
45
- stop
46
- start
43
+ restart
47
44
  end
48
45
 
49
46
  # Called on Ctrl-/ signal
@@ -57,6 +54,11 @@ module Guard
57
54
  restart
58
55
  end
59
56
 
57
+ def restart
58
+ stop
59
+ start
60
+ end
61
+
60
62
  private
61
63
 
62
64
  def cmd
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module ResqueVersion
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-resque
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2011-09-29 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: guard
17
- requirement: &2156499200 !ruby/object:Gem::Requirement
17
+ requirement: &2152972120 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0.8'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2156499200
25
+ version_requirements: *2152972120
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: resque
28
- requirement: &2156498360 !ruby/object:Gem::Requirement
28
+ requirement: &2152971620 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2156498360
36
+ version_requirements: *2152971620
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bundler
39
- requirement: &2156496840 !ruby/object:Gem::Requirement
39
+ requirement: &2152970780 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.0.10
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2156496840
47
+ version_requirements: *2152970780
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rspec
50
- requirement: &2156494660 !ruby/object:Gem::Requirement
50
+ requirement: &2152970100 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 2.5.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2156494660
58
+ version_requirements: *2152970100
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: guard-rspec
61
- requirement: &2156492420 !ruby/object:Gem::Requirement
61
+ requirement: &2152969320 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 0.2.0
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2156492420
69
+ version_requirements: *2152969320
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: guard-bundler
72
- requirement: &2156490760 !ruby/object:Gem::Requirement
72
+ requirement: &2152968740 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: 0.1.1
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *2156490760
80
+ version_requirements: *2152968740
81
81
  description: Guard::Resque automatically starts/stops/restarts resque worker
82
82
  email:
83
83
  - railsjedi@gmail.com