eye-patch 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/eye/patch/overrides.rb +47 -0
- data/lib/eye/patch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0232e86740d9e98145bf1f3270abdc9d7b5ef320
|
4
|
+
data.tar.gz: f007dccd24e1e8eb08739dd416a15d1389721514
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcdd3a0bdd31ecd1bafd14f4b46ba78d479aa90d64da8fc41fe99415a571eea5a466a05997b8f97ae7f964335a6378a90fc5267f1a19f3d7ed8a1f3c8b149704
|
7
|
+
data.tar.gz: d10ee77be22ffbe61648c680a44b89563e19aeb3e01590b90060fd9e5e8f47e7d05867abd9ecca97165e71aa6a79254dc4dbed5d42001a67e9330f4060377c1b
|
data/README.md
CHANGED
@@ -168,6 +168,12 @@ Note that if you _do_ need to persist file descriptors for a daemonized process,
|
|
168
168
|
|
169
169
|
Note also that since Ruby 2.0, file descriptors are closed when a process is invoked through `bundle exec`. From versions 1.5 and above, you can pass the `--keep-file-descriptors` flag to `bundle exec` to prevent this behavior.
|
170
170
|
|
171
|
+
#### Managing Pidfiles
|
172
|
+
|
173
|
+
By default, `eye` will attempt to manage the pidfile for any process with the `daemonize: true` flag. In certain cases, this may be undesirable. For example, [`unicorn`](https://github.com/defunkt/unicorn) attempts to manage its own pid, which is necessary for zero-downtime deploys.
|
174
|
+
|
175
|
+
To get around this problem, you can supply the `smart_pid: true` option in a process's config hash. This will instruct eye to trust the daemonized process to manage its own pid.
|
176
|
+
|
171
177
|
### Running Locally
|
172
178
|
|
173
179
|
You can test your configurations locally by running the `eye-patch` binary like so:
|
data/lib/eye/patch/overrides.rb
CHANGED
@@ -7,6 +7,53 @@ Eye::Cli.class_eval do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
require "eye/utils/mini_active_support"
|
11
|
+
Eye::Process.class_eval do
|
12
|
+
|
13
|
+
def daemonize_process
|
14
|
+
time_before = Time.now
|
15
|
+
res = Eye::System.daemonize(self[:start_command], config)
|
16
|
+
start_time = Time.now - time_before
|
17
|
+
|
18
|
+
info "daemonizing: `#{self[:start_command]}` with start_grace: #{self[:start_grace].to_f}s, env: #{self[:environment].inspect}, working_dir: #{self[:working_dir]}, <#{res[:pid]}>"
|
19
|
+
|
20
|
+
if res[:error]
|
21
|
+
|
22
|
+
if res[:error].message == 'Permission denied - open'
|
23
|
+
error "daemonize failed with #{res[:error].inspect}; make sure #{[self[:stdout], self[:stderr]]} are writable"
|
24
|
+
else
|
25
|
+
error "daemonize failed with #{res[:error].inspect}"
|
26
|
+
end
|
27
|
+
|
28
|
+
return {:error => res[:error].inspect}
|
29
|
+
end
|
30
|
+
|
31
|
+
self.pid = res[:pid]
|
32
|
+
|
33
|
+
unless self.pid
|
34
|
+
error 'no pid was returned'
|
35
|
+
return {:error => :empty_pid}
|
36
|
+
end
|
37
|
+
|
38
|
+
sleep_grace(:start_grace)
|
39
|
+
|
40
|
+
unless process_really_running?
|
41
|
+
error "process <#{self.pid}> not found, it may have crashed (#{check_logs_str})"
|
42
|
+
return {:error => :not_really_running}
|
43
|
+
end
|
44
|
+
|
45
|
+
unless !self[:smart_pid] && failsafe_save_pid
|
46
|
+
return {:error => :cant_write_pid}
|
47
|
+
end
|
48
|
+
|
49
|
+
res
|
50
|
+
end
|
51
|
+
|
52
|
+
def control_pid?
|
53
|
+
!!self[:daemonize] && !self[:smart_pid]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
10
57
|
Eye::System.class_eval do
|
11
58
|
class << self
|
12
59
|
alias_method :daemonize_without_hook, :daemonize
|
data/lib/eye/patch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eye-patch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Horner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eye
|