guard-redis 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/lib/guard/redis.rb +49 -13
- data/lib/guard/redis/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fae5b604bb544bddec0334ad7491722faeb5f594
|
4
|
+
data.tar.gz: 0eac208b2d898a82e129fa9cad1323021b76036c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77e10fae981ebba8c99b81a477224d166ab5bb4b06f2bbc5e779489ce5bed111df3b7007b37a04e6337200470e4cfabd0ba2d18dba59b2bc7f15dc406fbffd3d
|
7
|
+
data.tar.gz: 51ead19490a1e9fe643c79b2c4eed906e35df60221591e7ef316d504018f4fb15655e35d5ddc7b035d5c574a45fae4356df348af25bae41d3ca118a75e3017c2
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ It takes several options related to its configuration.
|
|
38
38
|
|
39
39
|
### List of available options
|
40
40
|
~~~~ruby
|
41
|
-
:executable => "/path/to/redis
|
41
|
+
:executable => "/path/to/redis-server/executable" # Set the custom path to the Redis server executable
|
42
42
|
:port => 9999 # Set a custom port number the Redis server is running on
|
43
43
|
:pidfile => "/var/pid/redis.pid" # Set a custom path the where the pidfile is written
|
44
44
|
:reload_on_change => false # Reload Redis if any of the specified files change. Note that you
|
@@ -53,5 +53,14 @@ It takes several options related to its configuration.
|
|
53
53
|
# these options to ensure it does so cleanly before reloading with :reload_on_change.
|
54
54
|
~~~~
|
55
55
|
|
56
|
+
### Pidfile location must be writable
|
57
|
+
Starting with version 2.0.0, the pidfile location you specify or the *default*
|
58
|
+
location (`/tmp/redis.pid`) if you don't specify **must be writable** or
|
59
|
+
guard-redis will fail to start.
|
60
|
+
|
61
|
+
**If you specify a pidfile location via the configuration and the directory path
|
62
|
+
doesn't exist, guard-redis will attempt to create it**. If it cannot write to that
|
63
|
+
directory, you will see an error and redis will fail to start.
|
64
|
+
|
56
65
|
## Contributors
|
57
66
|
Thanks so much to [all who have contributed](https://github.com/whazzmaster/guard-redis/graphs/contributors)!
|
data/lib/guard/redis.rb
CHANGED
@@ -3,21 +3,30 @@ require 'guard/compat/plugin'
|
|
3
3
|
module Guard
|
4
4
|
class Redis < Plugin
|
5
5
|
def start
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
@started = false
|
7
|
+
begin
|
8
|
+
ensure_pidfile_directory
|
9
|
+
UI.info "Starting Redis on port #{port}..."
|
10
|
+
IO.popen("#{executable} -", 'w+') do |server|
|
11
|
+
server.write(config)
|
12
|
+
server.close_write
|
13
|
+
end
|
14
|
+
UI.info "Redis is running with PID #{pid}"
|
15
|
+
@started = last_operation_succeeded?
|
16
|
+
rescue ::Exception => err
|
17
|
+
UI.error "Redis not started due to errors: #{err}"
|
12
18
|
end
|
13
|
-
|
14
|
-
last_operation_succeeded?
|
19
|
+
@started
|
15
20
|
end
|
16
21
|
|
17
22
|
def stop
|
18
|
-
|
19
|
-
|
20
|
-
|
23
|
+
if redis_started?
|
24
|
+
shutdown_redis
|
25
|
+
true
|
26
|
+
else
|
27
|
+
UI.info "Redis never started. No need to shutdown."
|
28
|
+
true
|
29
|
+
end
|
21
30
|
end
|
22
31
|
|
23
32
|
def reload
|
@@ -35,6 +44,10 @@ module Guard
|
|
35
44
|
reload if reload_on_change?
|
36
45
|
end
|
37
46
|
|
47
|
+
def redis_started?
|
48
|
+
@started
|
49
|
+
end
|
50
|
+
|
38
51
|
def shutdown_redis
|
39
52
|
return UI.info "No instance of Redis to stop." unless pid
|
40
53
|
return UI.info "Redis (#{pid}) was already stopped." unless process_running?
|
@@ -56,8 +69,20 @@ module Guard
|
|
56
69
|
}
|
57
70
|
end
|
58
71
|
|
72
|
+
def ensure_pidfile_directory
|
73
|
+
pidfile_dir = File.dirname(pidfile_path)
|
74
|
+
unless Dir.exist? pidfile_dir
|
75
|
+
UI.info "Creating pidfie directory #{pidfile_dir}"
|
76
|
+
FileUtils.mkdir_p pidfile_dir
|
77
|
+
end
|
78
|
+
|
79
|
+
unless File.writable? pidfile_dir
|
80
|
+
raise "no write access to pidfile directory #{pidfile_dir}"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
59
84
|
def config
|
60
|
-
result = <<
|
85
|
+
result = <<END
|
61
86
|
daemonize yes
|
62
87
|
pidfile #{pidfile_path}
|
63
88
|
port #{port}
|
@@ -67,7 +92,18 @@ END
|
|
67
92
|
end
|
68
93
|
|
69
94
|
def pid
|
70
|
-
|
95
|
+
count = 0
|
96
|
+
loop do
|
97
|
+
if count > 5
|
98
|
+
raise "pidfile was never written to #{pidfile_path}"
|
99
|
+
end
|
100
|
+
|
101
|
+
break if File.exists? pidfile_path
|
102
|
+
UI.info "Waiting for pidfile to appear at #{pidfile_path}..."
|
103
|
+
count += 1
|
104
|
+
sleep 1
|
105
|
+
end
|
106
|
+
File.read(pidfile_path).to_i
|
71
107
|
end
|
72
108
|
|
73
109
|
def executable
|
data/lib/guard/redis/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachery Moneypenny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: redis
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: 1.3.6
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.4.
|
128
|
+
rubygems_version: 2.4.5
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: Guard gem for Redis
|