resqued 0.7.12 → 0.7.13

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: 217c9c390f76d08b6a1aa2e16f926681a0e6bb75
4
- data.tar.gz: 947f5a477ae6533808679d9bc43596415fe84131
3
+ metadata.gz: 661e830ef15b07d0ed331ab8b628cb59671689ed
4
+ data.tar.gz: 7f88d962a1b042b3729732eae6a1dfa77ac768af
5
5
  SHA512:
6
- metadata.gz: a327fea71345130cb1db0c66ddb3f385061323e6c1261fd25a3f785bee413f998523ce4aa4e1addf8339f58de4b7255b9b35b676225ee5290bbe9d31d4a0968f
7
- data.tar.gz: 5fda5a050c55ac5e7dbc911aceae8ba78a288f63fae042b57b88e13b9dcafe2ccec00ff4f87f2541f4bcba46ea2875a348630c85c55775c418b15f68915a2700
6
+ metadata.gz: b1d3e137b01bc0d71bc5c43f694286dd2ee1a4ea1ac0c9682779dc72eabd470c9042332b5736184491db41d75e63c0045d3d5afc861ac1f18a9ed52ea1c7fbcc
7
+ data.tar.gz: 4c96242b6bcfcb59d360aef1b0be97b75cfbe4d0cf9c67a286fb4fcd514786188432ac0c5845abbb62a39dd954a47cc6b22ae898d464e4853717c79394edaf68
data/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  Starting with version 0.6.1, resqued uses semantic versioning to indicate incompatibilities between the master process, listener process, and configuration.
2
2
 
3
+ v0.7.13
4
+ -------
5
+
6
+ * Support for symlinks in production environments. (#36)
7
+
3
8
  v0.7.12
4
9
  -------
5
10
 
data/README.md CHANGED
@@ -55,6 +55,36 @@ This time, you'd end up with something similar to this:
55
55
 
56
56
  * `:interval` - The interval to pass to `Resque::Worker#run`.
57
57
 
58
+ ## Launching in production.
59
+
60
+ Resqued restarts when its master process receives `SIGHUP`. It restarts by re-execing the command that you initially ran. There are two main recommendations for running in production.
61
+
62
+ * If you use bundler to install resqued, tell it to generate a binstub for resqued. Invoke this binstub (e.g. `bin/resqued`) when you start resqued.
63
+
64
+ * Specify a pid file using the `-p` option. This pidfile will have the PID of the master process. See [docs/signals.md](docs/signals.md) for more information about which signals are supported.
65
+
66
+ If your application is running from a symlinked dir (for example, [capistrano's "current" symlink](http://capistranorb.com/documentation/getting-started/structure/)), you'll need to do two more things:
67
+
68
+ * Ensure that your resqued master process is at least 0.7.13 (`ps o args= $RESQUED_MASTER_PID` should start with "resqued-0.7.13" or higher).
69
+
70
+ * Explicitly set the `BUNDLE_GEMFILE` environment variable to the symlink dir of your app.
71
+
72
+ * If you're invoking resqued from something that resolves symlinks in `pwd`, you'll also want to explicitly set the `PWD` environment variable.
73
+
74
+ Rolling all of the above advice together, here's a sample that you could use in an upstart script for resqued:
75
+
76
+ ```
77
+ # fragment of /etc/init/resqued.conf
78
+
79
+ kill signal QUIT
80
+
81
+ env BUNDLE_GEMFILE=/opt/app/current/Gemfile
82
+ env PWD=/opt/app/current
83
+ chdir /opt/app/current
84
+
85
+ exec bin/resqued -c config/resqued.rb -p /opt/app/shared/tmp/pids/resqued.pid
86
+ ```
87
+
58
88
  ## Compatibility with Resque
59
89
 
60
90
  Resqued does not automatically split comma-separated lists of queues in
data/exe/resqued CHANGED
@@ -61,7 +61,7 @@ if test
61
61
  end
62
62
  else
63
63
  require 'resqued'
64
- Resqued::START_CTX['$0'] = $0.dup
64
+ Resqued.capture_start_ctx!
65
65
  resqued = Resqued::Master.new(options)
66
66
  if daemonize
67
67
  require 'resqued/daemon'
data/lib/resqued.rb CHANGED
@@ -3,4 +3,21 @@ require 'resqued/version'
3
3
 
4
4
  module Resqued
5
5
  START_CTX = {}
6
+
7
+ def self.capture_start_ctx!
8
+ START_CTX['$0'] = $0.dup
9
+ START_CTX['pwd'] =
10
+ begin
11
+ env_pwd = ENV["PWD"]
12
+ env_pwd_stat = File.stat env_pwd
13
+ dir_pwd_stat = File.stat Dir.pwd
14
+ if env_pwd_stat.ino == dir_pwd_stat.ino && env_pwd_stat.dev == dir_pwd_stat.dev
15
+ env_pwd
16
+ else
17
+ Dir.pwd
18
+ end
19
+ rescue
20
+ Dir.pwd
21
+ end
22
+ end
6
23
  end
@@ -36,7 +36,11 @@ module Resqued
36
36
  ENV['RESQUED_LISTENER_ID'] = @listener_id.to_s
37
37
  ENV['RESQUED_MASTER_VERSION'] = Resqued::VERSION
38
38
  log "exec: #{Resqued::START_CTX['$0']} listener"
39
- Kernel.exec(Resqued::START_CTX['$0'], 'listener', socket_fd => socket_fd) # The hash at the end only works in new-ish (1.9+ or so) rubies. It's required for ruby 2.0.
39
+ exec_opts = {socket_fd => socket_fd} # Ruby 2.0 needs to be told to keep the file descriptor open during exec.
40
+ if start_pwd = Resqued::START_CTX['pwd']
41
+ exec_opts[:chdir] = start_pwd
42
+ end
43
+ Kernel.exec(Resqued::START_CTX['$0'], 'listener', exec_opts)
40
44
  end
41
45
 
42
46
  # Public: Given args from #exec, start this listener.
@@ -1,3 +1,3 @@
1
1
  module Resqued
2
- VERSION = '0.7.12'
2
+ VERSION = '0.7.13'
3
3
  end
@@ -0,0 +1,57 @@
1
+ require "spec_helper"
2
+ require "tmpdir"
3
+ require "resqued"
4
+
5
+ describe "Resqued::START_CTX" do
6
+ before do
7
+ Resqued::START_CTX.clear
8
+ end
9
+
10
+ it "captures '$0'" do
11
+ Resqued.capture_start_ctx!
12
+ expect(Resqued::START_CTX["$0"]).to be_a(String)
13
+ end
14
+
15
+ it "captures pwd" do
16
+ Resqued.capture_start_ctx!
17
+ expect(Resqued::START_CTX["pwd"]).to eq(Dir.pwd)
18
+ end
19
+
20
+ it "captures pwd without resolving symlinks" do
21
+ tmpdir = Dir.mktmpdir
22
+ begin
23
+ realdir = File.expand_path("#{tmpdir}/realdir")
24
+ linkdir = File.expand_path("#{tmpdir}/linked")
25
+
26
+ Dir.mkdir realdir
27
+ File.symlink "realdir", linkdir
28
+
29
+ original_pwd, ENV["PWD"] = ENV["PWD"], linkdir
30
+ Dir.chdir linkdir do
31
+ Resqued.capture_start_ctx!
32
+ expect(Resqued::START_CTX["pwd"]).to eq(linkdir)
33
+ end
34
+ ensure
35
+ ENV["PWD"] = original_pwd
36
+ FileUtils.remove_entry_secure(tmpdir)
37
+ end
38
+ end
39
+
40
+ it "captures pwd when ENV['PWD'] is wrong" do
41
+ tmpdir = Dir.mktmpdir
42
+ begin
43
+ realdir = File.expand_path("#{tmpdir}/realdir")
44
+ linkdir = File.expand_path("#{tmpdir}/linked")
45
+
46
+ Dir.mkdir realdir
47
+ File.symlink "realdir", linkdir
48
+
49
+ Dir.chdir linkdir do
50
+ Resqued.capture_start_ctx!
51
+ expect(Resqued::START_CTX["pwd"]).to eq(Dir.pwd)
52
+ end
53
+ ensure
54
+ FileUtils.remove_entry_secure(tmpdir)
55
+ end
56
+ end
57
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resqued
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.12
4
+ version: 0.7.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Burke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-02-03 00:00:00.000000000 Z
11
+ date: 2015-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kgio
@@ -123,6 +123,7 @@ files:
123
123
  - spec/resqued/config/worker_spec.rb
124
124
  - spec/resqued/config_spec.rb
125
125
  - spec/resqued/sleepy_spec.rb
126
+ - spec/resqued/start_ctx_spec.rb
126
127
  - spec/resqued/test_case_spec.rb
127
128
  - spec/spec_helper.rb
128
129
  - spec/support/custom_matchers.rb
@@ -163,6 +164,7 @@ test_files:
163
164
  - spec/resqued/config/worker_spec.rb
164
165
  - spec/resqued/config_spec.rb
165
166
  - spec/resqued/sleepy_spec.rb
167
+ - spec/resqued/start_ctx_spec.rb
166
168
  - spec/resqued/test_case_spec.rb
167
169
  - spec/spec_helper.rb
168
170
  - spec/support/custom_matchers.rb