lacquer 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,26 +1,28 @@
1
- development:
2
- listen: 127.0.0.1:3001
3
- telnet: 127.0.0.1:6082
4
- backend: 127.0.0.1:3000
5
- sbin_path: /usr/local/sbin
6
- storage: "file,#{Rails.root}/log/varnishd.#{Rails.env}.cache,100MB"
7
-
8
- test:
9
- listen: 127.0.0.1:3002
10
- telnet: 127.0.0.1:6083
11
- backend: 127.0.0.1:3000
12
- sbin_path: /usr/local/sbin
13
- storage: "file,#{Rails.root}/log/varnishd.#{Rails.env}.cache,100MB"
14
-
15
- production:
16
- listen: :80
17
- telnet: localhost:6082
18
- backend: backend_server:8080
19
- sbin_path: /usr/local/sbin
20
- storage: "file,#{Rails.root}/log/varnishd.#{Rails.env}.cache,100MB"
21
- params:
22
- overflow_max: 2000 # for Varnish 2.x ... use "queue_max: 2000" for Varnish 3.x
23
- thread_pool_add_delay: 2
24
- thread_pools: 4 # <Number of cpu cores>
25
- thread_pool_min: 200 # <800/number of cpu cores>
26
- thread_pool_max: 4000
1
+ development:
2
+ listen: 127.0.0.1:3001
3
+ telnet: 127.0.0.1:6082
4
+ backend: 127.0.0.1:3000
5
+ sbin_path: /usr/local/sbin
6
+ storage: "file,#{Rails.root}/log/varnishd.#{Rails.env}.cache,100MB"
7
+
8
+ test:
9
+ listen: 127.0.0.1:3002
10
+ telnet: 127.0.0.1:6083
11
+ backend: 127.0.0.1:3000
12
+ sbin_path: /usr/local/sbin
13
+ storage: "file,#{Rails.root}/log/varnishd.#{Rails.env}.cache,100MB"
14
+
15
+ production:
16
+ listen: :80
17
+ telnet: localhost:6082
18
+ backend: backend_server:8080
19
+ use_sudo: false
20
+ sbin_path: /usr/local/sbin
21
+ pid_path: <%= Rails.root.join('log') %>
22
+ storage: "file,#{Rails.root}/log/varnishd.#{Rails.env}.cache,100MB"
23
+ params:
24
+ overflow_max: 2000 # for Varnish 2.x ... use "queue_max: 2000" for Varnish 3.x
25
+ thread_pool_add_delay: 2
26
+ thread_pools: 4 # <Number of cpu cores>
27
+ thread_pool_min: 200 # <800/number of cpu cores>
28
+ thread_pool_max: 4000
@@ -26,6 +26,9 @@ module Lacquer
26
26
  # Pass Command (in vcl_fetch)
27
27
  attr_accessor :pass_command
28
28
 
29
+ # Use sudo for start up
30
+ attr_accessor :use_sudo
31
+
29
32
  def initialize
30
33
  @enable_cache = true
31
34
  @varnish_servers = []
@@ -35,6 +38,7 @@ module Lacquer
35
38
  @command_error_handler = nil
36
39
  @purge_command = "url.purge"
37
40
  @pass_command = "pass"
41
+ @use_sudo = false
38
42
  end
39
43
 
40
44
  # Returns a hash of all configurable options
@@ -1,6 +1,6 @@
1
1
  module Lacquer
2
2
  class Varnishd
3
- attr_accessor :listen, :telnet, :sbin_path, :storage, :working_dir, :user, :backend, :params
3
+ attr_accessor :listen, :telnet, :sbin_path, :storage, :working_dir, :user, :backend, :params, :use_sudo, :pid_path
4
4
 
5
5
  cattr_accessor :started_check_delay, :vcl_script_filename
6
6
  self.started_check_delay = 1
@@ -23,8 +23,8 @@ module Lacquer
23
23
  end
24
24
 
25
25
  def initialize(settings = self.class.config)
26
- self.listen, self.telnet, self.backend, self.sbin_path, self.storage, self.working_dir, self.user, self.params =
27
- settings.values_at("listen", "telnet", "backend", "sbin_path", "storage", "working_dir", "user", "params")
26
+ self.listen, self.telnet, self.backend, self.sbin_path, self.storage, self.working_dir, self.user, self.params, self.use_sudo, self.pid_path =
27
+ settings.values_at("listen", "telnet", "backend", "sbin_path", "storage", "working_dir", "user", "params", "use_sudo", "pid_path")
28
28
  end
29
29
 
30
30
  def render_vcl
@@ -55,7 +55,7 @@ module Lacquer
55
55
 
56
56
  def stop
57
57
  if running?
58
- execute("kill #{pid}")
58
+ execute("#{'sudo ' if use_sudo}kill #{pid}")
59
59
  pid_file.delete
60
60
  else
61
61
  log("pid file not found or varnishd not running")
@@ -63,9 +63,7 @@ module Lacquer
63
63
  end
64
64
 
65
65
  def running?
66
- !!pid && !!Process.kill(0, pid.to_i)
67
- rescue
68
- false
66
+ !!pid && !!execute("ps p #{pid}").include?(pid.to_s) # works with sudo
69
67
  end
70
68
 
71
69
  def args
@@ -95,11 +93,19 @@ module Lacquer
95
93
  protected
96
94
 
97
95
  def varnishd_cmd
98
- Pathname.new(sbin_path).join('varnishd')
96
+ "#{'sudo ' if use_sudo}#{Pathname.new(sbin_path).join('varnishd')}"
99
97
  end
100
98
 
101
99
  def pid_file
102
- self.class.root_path.join("log/varnishd.#{self.class.env}.pid")
100
+ pid_computed_path.join("varnishd.#{self.class.env}.pid")
101
+ end
102
+
103
+ def pid_computed_path
104
+ if self.pid_path
105
+ Pathname.new self.pid_path
106
+ else
107
+ self.class.root_path.join('log/')
108
+ end
103
109
  end
104
110
 
105
111
  def vcl_script_filename
@@ -1,3 +1,3 @@
1
1
  module Lacquer
2
- VERSION = '0.5.6'
2
+ VERSION = '0.5.7'
3
3
  end
@@ -6,5 +6,6 @@ test:
6
6
  storage: "file,#{Rails.root}/log/varnish,1GB"
7
7
  working_dir: ""
8
8
  user: "deploy"
9
+ use_sudo: true
9
10
  params:
10
11
  overflow_max: 2000
@@ -27,6 +27,7 @@ describe "Varnishd" do
27
27
  Lacquer::Varnishd.config.should have_key("telnet")
28
28
  Lacquer::Varnishd.config.should have_key("sbin_path")
29
29
  Lacquer::Varnishd.config.should have_key("storage")
30
+ Lacquer::Varnishd.config.should have_key("use_sudo")
30
31
  Lacquer::Varnishd.config["params"].should have_key('overflow_max')
31
32
  end
32
33
 
@@ -35,11 +36,21 @@ describe "Varnishd" do
35
36
  Lacquer::Varnishd.new("sbin_path" => "/opt/varnishd/sbin").start
36
37
  end
37
38
 
39
+ it "returns full path to varnishd using sudo" do
40
+ executes_with(%r[sudo /opt/varnishd/sbin/varnishd])
41
+ Lacquer::Varnishd.new("sbin_path" => "/opt/varnishd/sbin", "use_sudo" => true).start
42
+ end
43
+
38
44
  it "returns pid file" do
39
45
  executes_with(/log\/varnishd.test.pid/)
40
46
  Lacquer::Varnishd.new("sbin_path" => "/opt/varnishd/sbin").start
41
47
  end
42
48
 
49
+ it "returns pid file with custom path" do
50
+ executes_with(/pid\/varnishd.test.pid/)
51
+ Lacquer::Varnishd.new("sbin_path" => "/opt/varnishd/sbin", "pid_path" => "pid/").start
52
+ end
53
+
43
54
  it "returns params as string" do
44
55
  Lacquer::Varnishd.new("params" => { "max" => 2000, "add" => 2 }).params_args.should == "-p max=2000 -p add=2"
45
56
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lacquer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,11 +12,11 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-05-02 00:00:00.000000000Z
15
+ date: 2012-10-04 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
19
- requirement: &70253394615980 !ruby/object:Gem::Requirement
19
+ requirement: !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,10 +24,15 @@ dependencies:
24
24
  version: 2.3.10
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *70253394615980
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.3.10
28
33
  - !ruby/object:Gem::Dependency
29
34
  name: i18n
30
- requirement: &70253394614860 !ruby/object:Gem::Requirement
35
+ requirement: !ruby/object:Gem::Requirement
31
36
  none: false
32
37
  requirements:
33
38
  - - ~>
@@ -35,10 +40,15 @@ dependencies:
35
40
  version: '0.4'
36
41
  type: :runtime
37
42
  prerelease: false
38
- version_requirements: *70253394614860
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: '0.4'
39
49
  - !ruby/object:Gem::Dependency
40
50
  name: erubis
41
- requirement: &70253394613740 !ruby/object:Gem::Requirement
51
+ requirement: !ruby/object:Gem::Requirement
42
52
  none: false
43
53
  requirements:
44
54
  - - ! '>='
@@ -46,10 +56,15 @@ dependencies:
46
56
  version: '0'
47
57
  type: :runtime
48
58
  prerelease: false
49
- version_requirements: *70253394613740
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
50
65
  - !ruby/object:Gem::Dependency
51
66
  name: rake
52
- requirement: &70253394612340 !ruby/object:Gem::Requirement
67
+ requirement: !ruby/object:Gem::Requirement
53
68
  none: false
54
69
  requirements:
55
70
  - - ! '>='
@@ -57,10 +72,15 @@ dependencies:
57
72
  version: '0'
58
73
  type: :development
59
74
  prerelease: false
60
- version_requirements: *70253394612340
75
+ version_requirements: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
61
81
  - !ruby/object:Gem::Dependency
62
82
  name: rspec
63
- requirement: &70253394610860 !ruby/object:Gem::Requirement
83
+ requirement: !ruby/object:Gem::Requirement
64
84
  none: false
65
85
  requirements:
66
86
  - - ~>
@@ -68,10 +88,15 @@ dependencies:
68
88
  version: '2.5'
69
89
  type: :development
70
90
  prerelease: false
71
- version_requirements: *70253394610860
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '2.5'
72
97
  - !ruby/object:Gem::Dependency
73
98
  name: yard
74
- requirement: &70253394610320 !ruby/object:Gem::Requirement
99
+ requirement: !ruby/object:Gem::Requirement
75
100
  none: false
76
101
  requirements:
77
102
  - - ! '>='
@@ -79,7 +104,12 @@ dependencies:
79
104
  version: '0'
80
105
  type: :development
81
106
  prerelease: false
82
- version_requirements: *70253394610320
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
83
113
  description: Rails drop in for Varnish support.
84
114
  email: russ@bashme.org
85
115
  executables: []
@@ -146,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
176
  version: '0'
147
177
  requirements: []
148
178
  rubyforge_project: lacquer
149
- rubygems_version: 1.8.10
179
+ rubygems_version: 1.8.23
150
180
  signing_key:
151
181
  specification_version: 3
152
182
  summary: Rails drop in for Varnish support.