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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8281021f4db405a7011e70f5ea0f01aa0b1afc3
4
- data.tar.gz: 4ac4ff0e9c9b16f55912ffe1a885af3d424e6819
3
+ metadata.gz: 0232e86740d9e98145bf1f3270abdc9d7b5ef320
4
+ data.tar.gz: f007dccd24e1e8eb08739dd416a15d1389721514
5
5
  SHA512:
6
- metadata.gz: 9f58bfc30efef715e657c4c76611f9eda3040fa7ae8ebba0ca0c3b5f84ec997ddc65be39bf80ecb101ae2983f215a087106a8ee04c9e144df1daa6715bdf29a6
7
- data.tar.gz: 667974afe57844d67faadc9ecc7bcd4926b19d982285d525f92c181224ef081c012a208da434dad5a2afea309dd6b4689371ce0f6faa9fc17972fc653cdebefa
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:
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Eye
2
2
  module Patch
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
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.5
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-03-03 00:00:00.000000000 Z
11
+ date: 2014-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eye