guard-redis 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c9e97b9b31760dbdb3a1b76a47d4fe6a30bcb6fa
4
+ data.tar.gz: 8fa5b34132dbdc6b84360c3cdd8e0ff4c404a1ef
5
+ SHA512:
6
+ metadata.gz: 3827eed1ebf25253db43d8abc3336d2a943732f9bf2dfc07ffb24e4d817e99dba82b4466cd57a20d31b9f7239a355322ce239173b16e0cbae42777bb090bbdf1
7
+ data.tar.gz: 59d9d85069adbcd036d9d6ee0fbfcef8065359058f2997e38e051c526f3c2d0171f6fce7bb2d9c92f3829f2f0a43ced1fedd7056e3eb119ea37f68694d16d6be
data/README.md CHANGED
@@ -33,8 +33,16 @@ It takes several options related to its configuration.
33
33
  :pidfile => "/var/pid/redis.pid" # Set a custom path the where the pidfile is written
34
34
  :reload_on_change => false # Reload Redis if any of the specified files change. Note that you
35
35
  # must specify this option in addition to passing a block to Guard.
36
+ :capture_logging => true # Enables logging to :logfile
37
+ :logfile => "log/redis_#{port}.log" # Set a custom path where logs from Redis are written
38
+ # Since by default the output from Redis goes to the ether, these options
39
+ # let you redirect logging to a file to assist with debugging crashes
40
+ :shutdown_retries => 3 # Set a number of times to retry
41
+ :shutdown_wait => 5 # Set a number of seconds to wait between retries
42
+ # Sometimes Redis takes more than a moment to shut down and you can use
43
+ # these options to ensure it does so cleanly before reloading with :reload_on_change.
36
44
  ~~~~
37
45
 
38
- ## Contributers
46
+ ## Contributors
39
47
 
40
48
  https://github.com/whazzmaster/guard-redis/graphs/contributors
data/lib/guard/redis.rb CHANGED
@@ -16,12 +16,9 @@ module Guard
16
16
  end
17
17
 
18
18
  def stop
19
- if pid
20
- UI.info "Sending TERM signal to Redis (#{pid})"
21
- Process.kill("TERM", pid)
22
- @pid = nil
23
- true
24
- end
19
+ shutdown_redis
20
+ @pid = nil
21
+ true
25
22
  end
26
23
 
27
24
  def reload
@@ -39,6 +36,21 @@ module Guard
39
36
  reload if reload_on_change?
40
37
  end
41
38
 
39
+ def shutdown_redis
40
+ return UI.info "No instance of Redis to stop." unless pid
41
+ return UI.info "Redis (#{pid}) was already stopped." unless process_running?
42
+ UI.info "Sending TERM signal to Redis (#{pid})..."
43
+ Process.kill("TERM", pid)
44
+
45
+ return if shutdown_retries == 0
46
+ shutdown_retries.times do
47
+ return UI.info "Redis stopped." unless process_running?
48
+ UI.info "Redis is still shutting down. Retrying in #{ shutdown_wait } second(s)..."
49
+ sleep shutdown_wait
50
+ end
51
+ UI.error "Redis didn't shut down after #{ shutdown_retries * shutdown_wait } second(s)."
52
+ end
53
+
42
54
  def pidfile_path
43
55
  options.fetch(:pidfile) {
44
56
  File.expand_path('/tmp/redis.pid', File.dirname(__FILE__))
@@ -46,11 +58,13 @@ module Guard
46
58
  end
47
59
 
48
60
  def config
49
- <<"END"
61
+ result = <<"END"
50
62
  daemonize yes
51
63
  pidfile #{pidfile_path}
52
64
  port #{port}
53
65
  END
66
+ result << "logfile #{logfile}" if capture_logging?
67
+ result
54
68
  end
55
69
 
56
70
  def pid
@@ -65,6 +79,20 @@ END
65
79
  options.fetch(:port) { 6379 }
66
80
  end
67
81
 
82
+ def logfile
83
+ options.fetch(:logfile) {
84
+ if capture_logging? then "log/redis_#{port}.log" else 'stdout' end
85
+ }
86
+ end
87
+
88
+ def shutdown_retries
89
+ options.fetch(:shutdown_retries) { 0 }
90
+ end
91
+
92
+ def shutdown_wait
93
+ options.fetch(:shutdown_wait) { 0 }
94
+ end
95
+
68
96
  def last_operation_succeeded?
69
97
  $?.success?
70
98
  end
@@ -72,5 +100,18 @@ END
72
100
  def reload_on_change?
73
101
  options.fetch(:reload_on_change) { false }
74
102
  end
103
+
104
+ def process_running?
105
+ begin
106
+ Process.getpgid pid
107
+ true
108
+ rescue Errno::ESRCH
109
+ false
110
+ end
111
+ end
112
+
113
+ def capture_logging?
114
+ options.fetch(:capture_logging) { false }
115
+ end
75
116
  end
76
117
  end
@@ -1,4 +1,4 @@
1
- # Possible options are :port, :executable, :pidfile, and :reload_on_change
1
+ # Possible options are :port, :executable, :pidfile, :reload_on_change, :capture_logging, :logfile, :shutdown_retries, :shutdown_wait
2
2
 
3
3
  # Default implementation - starts Redis on standard port and stops on exit
4
4
  guard 'redis'
@@ -9,3 +9,9 @@ guard 'redis'
9
9
  # guard 'redis', :executable => 'redis-server', :pidfile => 'tmp/pids/redis.pid', :port => 6379, :reload_on_change => true do
10
10
  # watch(/^(app|lib|config)\/.*\.rb$/)
11
11
  # end
12
+
13
+ # Same as above - also enable Redis logging and 3 shutdown retries spaced 5 seconds apart
14
+ #
15
+ # guard 'redis', :executable => 'redis-server', :pidfile => 'tmp/pids/redis.pid', :port => 6379, :reload_on_change => true, :capture_logging => true, :logfile => 'log/redis.log', :shutdown_retries => 3, :shutdown_wait => 5 do
16
+ # watch(/^(app|lib|config)\/.*\.rb$/)
17
+ # end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module RedisVersion
3
- VERSION = "0.2.2"
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,52 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Zachery Moneypenny
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-25 00:00:00.000000000 Z
11
+ date: 2013-08-26 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: guard
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.4.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.4.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: redis
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 2.2.2
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 2.2.2
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bundler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,17 +69,15 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: guard-rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: Guard::Redis automatically starts and restarts your local redis server.
@@ -105,26 +94,25 @@ files:
105
94
  - README.md
106
95
  homepage: http://rubygems.org/gems/guard-redis
107
96
  licenses: []
97
+ metadata: {}
108
98
  post_install_message:
109
99
  rdoc_options: []
110
100
  require_paths:
111
101
  - lib
112
102
  required_ruby_version: !ruby/object:Gem::Requirement
113
- none: false
114
103
  requirements:
115
- - - ! '>='
104
+ - - '>='
116
105
  - !ruby/object:Gem::Version
117
106
  version: '0'
118
107
  required_rubygems_version: !ruby/object:Gem::Requirement
119
- none: false
120
108
  requirements:
121
- - - ! '>='
109
+ - - '>='
122
110
  - !ruby/object:Gem::Version
123
111
  version: 1.3.6
124
112
  requirements: []
125
113
  rubyforge_project:
126
- rubygems_version: 1.8.23
114
+ rubygems_version: 2.0.3
127
115
  signing_key:
128
- specification_version: 3
116
+ specification_version: 4
129
117
  summary: Guard gem for Redis
130
118
  test_files: []