cany 0.1.3 → 0.2.0

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: a8ffadee6ad8d67a8875afc014992492b3e55119
4
- data.tar.gz: c109aa1b6c99f0075b68e5e182f90ad992401161
3
+ metadata.gz: 8b17f53a807349e5ba0daab0b18ed9aaebf0998b
4
+ data.tar.gz: ea9b74995db2691b0a783192f8c408ce12dd4dd5
5
5
  SHA512:
6
- metadata.gz: 7b6df83b694ce69713bba4e04542964fd5f3502f890a01a4a804d607cceee51ae1e3d0a658e46d198d09fb3a08e13913b67ce9b146d7f9864e52bc9d1c4849ed
7
- data.tar.gz: 6975b1e62035ae0e644f1caab4216e864076fc5d666f080d7ca9fcbb118caff00cafa2b397b95861fedfab82c48800822b2183fb93041e93116a4465d9705f1e
6
+ metadata.gz: 5d0cd4134c0e0a841019f9509202a140a7231fc2ccfe46aad6bdf108240787c930fd98ab5584a20080b8f898338d04256c126728da854b4fb1b0a2af65d21658
7
+ data.tar.gz: 2ac9ce3592f29db17c162a902a70ed27da9cc0d92874f985ac00f1765ce200c0f6b467e5174f107aafccccdb041e25c07118ce8f84ce6a6cc05fd04cd84c791d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ 0.2.0 / 2013-09-25
2
+ ==================
3
+
4
+ Feature:
5
+
6
+ * sidekiq: option to specify as which user and group sidekiq should run
7
+ * web server: option to specify as which user and group the web server should run (thin, unicorn)
8
+
9
+
1
10
  0.1.3 / 2013-09-25
2
11
  ==================
3
12
 
@@ -10,7 +19,7 @@ Bug Fixes:
10
19
  ==================
11
20
 
12
21
  Bug Fixes:
13
-
22
+
14
23
  * dpkg: fix build error with --no-arch-all
15
24
  * recipe: fix web server pre start scripts
16
25
 
@@ -3,15 +3,28 @@ module Cany::Recipes
3
3
  # "Simple, efficient, background processing in Ruby"
4
4
  # Sidekiq is registered as service and so automatically started.
5
5
  # @see http://sidekiq.org/ The official website for more information.
6
- # @node The recipe relies that 'sidekiq' is listed inside your Gemfile and
6
+ # @note The recipe relies that 'sidekiq' is listed inside your Gemfile and
7
7
  # therefore installed via the 'bundler' recipe.
8
+ #
9
+ # @!attribute queues
10
+ # @return [Array<String>, nil] An (optional) list of queue names sidekiq
11
+ # should listen on
12
+ # @!attribute user
13
+ # @return [String, nil] The user name as which the sidekiq process should
14
+ # executed
15
+ # @!attribute group
16
+ # @return [String, nil] The group name as which the sidekiq process should
17
+ # executed
8
18
  class Sidekiq < Cany::Recipe
9
19
  register_as :sidekiq
10
20
 
11
21
  attr_accessor :queues
22
+ attr_accessor :user, :group
12
23
 
13
24
  def initialize(*args)
14
25
  @queues = []
26
+ @user = 'www-data'
27
+ @group = 'www-data'
15
28
  super
16
29
  end
17
30
 
@@ -19,10 +32,11 @@ module Cany::Recipes
19
32
  def queue(name)
20
33
  @recipe.queues << name
21
34
  end
35
+ delegate :user, :group
22
36
  end
23
37
 
24
38
  def binary
25
- install_service name, %W(/usr/bin/#{spec.name} sidekiq) + sidekiq_args, user: 'www-data', group: 'www-data'
39
+ install_service name, %W(/usr/bin/#{spec.name} sidekiq) + sidekiq_args, user: user, group: group
26
40
  inner.binary
27
41
  end
28
42
 
@@ -15,7 +15,7 @@ module Cany::Recipes
15
15
  register_as :thin
16
16
 
17
17
  def launch_command
18
- %W(thin start -C /etc/#{spec.name}/thin.yml")
18
+ %W(thin start --config /etc/#{spec.name}/thin.yml)
19
19
  end
20
20
 
21
21
  def binary
@@ -1,14 +1,29 @@
1
- module Cany
2
- module Recipes
3
- class WebServer < Recipe
4
- def binary
5
- recipe(:system).configure :service_pre_scripts, {
6
- mkdir_run: "mkdir -p /var/run/#{spec.name}",
7
- chown_run: "chown www-data /var/run/#{spec.name}"
8
- }
9
- install_service name, ["/usr/bin/#{spec.name}"] + launch_command, user: 'www-data', group: 'www-data'
10
- inner.binary
11
- end
1
+ module Cany::Recipes
2
+ # @!attribute user
3
+ # @return [String, nil] The user name as which the web server process should
4
+ # executed
5
+ # @!attribute group
6
+ # @return [String, nil] The group name as which the web server process should
7
+ # executed
8
+ class WebServer < Cany::Recipe
9
+ attr_accessor :user, :group
10
+ class DSL < Cany::Recipe::DSL
11
+ delegate :user, :group
12
+ end
13
+
14
+ def initialize(*args)
15
+ @user = 'www-data'
16
+ @group = 'www-data'
17
+ super
18
+ end
19
+
20
+ def binary
21
+ recipe(:system).configure :service_pre_scripts, {
22
+ mkdir_run: "mkdir -p /var/run/#{spec.name}",
23
+ chown_run: "chown #{user}:#{group} /var/run/#{spec.name}"
24
+ }
25
+ install_service name, ["/usr/bin/#{spec.name}"] + launch_command, user: user, group: group
26
+ inner.binary
12
27
  end
13
28
  end
14
29
  end
data/lib/cany/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Cany
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 1
5
- PATCH = 3
4
+ MINOR = 2
5
+ PATCH = 0
6
6
  STAGE = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.')
8
8
  def self.to_s; STRING end
@@ -28,6 +28,7 @@ describe Cany::Recipes::Sidekiq do
28
28
  end
29
29
  end
30
30
  end
31
+
31
32
  context 'with queue names' do
32
33
  before do
33
34
  spec.setup do
@@ -49,4 +50,26 @@ describe Cany::Recipes::Sidekiq do
49
50
  recipe.binary
50
51
  end
51
52
  end
53
+
54
+ context 'with defined user/group' do
55
+ before do
56
+ spec.setup do
57
+ use :sidekiq do
58
+ user 'user'
59
+ group 'group'
60
+ end
61
+ end
62
+ end
63
+
64
+ it 'should launch sidekiq with as this user and group' do
65
+ expect(recipe).to receive(:install_service).with(
66
+ :sidekiq,
67
+ %w(/usr/bin/test sidekiq --environment production),
68
+ user: 'user', group: 'group'
69
+ )
70
+ recipe.inner = double('recipe')
71
+ expect(recipe.inner).to receive(:binary)
72
+ recipe.binary
73
+ end
74
+ end
52
75
  end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cany::Recipes::Thin do
4
+ let(:setup) { proc { use :thin } }
5
+ let(:spec) do
6
+ Cany::Specification.new do
7
+ name 'test'
8
+ end
9
+ end
10
+ let(:recipe) { spec.recipes.first }
11
+ let(:system_recipe) { Cany::Dpkg::DebHelperRecipe.new(spec) }
12
+ let(:pre_scripts) { system_recipe.option(:service_pre_scripts) }
13
+ subject { recipe.binary }
14
+
15
+ context '#binary' do
16
+ before do
17
+ spec.setup &setup
18
+ spec.system_recipe = system_recipe
19
+ recipe.inner = double('recipe')
20
+ expect(recipe.inner).to receive(:binary)
21
+ end
22
+
23
+ context 'without configuration' do
24
+ it 'should launch unicorn only with environment specification and config file' do
25
+ expect(recipe).to receive(:install_service).with(
26
+ :thin,
27
+ %w(/usr/bin/test thin start --config /etc/test/thin.yml),
28
+ user: 'www-data', group: 'www-data'
29
+ )
30
+ expect(recipe).to receive(:install_content).with '/etc/test/thin.yml', <<CONFIG
31
+ ---
32
+ environment: production
33
+ socket: /var/run/test/sock
34
+ pid: /var/run/test/thin.pid
35
+ CONFIG
36
+ subject
37
+ expect(pre_scripts).to eq({
38
+ mkdir_run: 'mkdir -p /var/run/test',
39
+ chown_run: 'chown www-data:www-data /var/run/test'
40
+ })
41
+ end
42
+ end
43
+
44
+ context 'with defined user/group' do
45
+ let(:setup) { proc { use(:thin) { user 'user'; group 'group' } } }
46
+
47
+ it 'should launch unicorn with as this user and group' do
48
+ expect(recipe).to receive(:install_service).with(
49
+ :thin,
50
+ %w(/usr/bin/test thin start --config /etc/test/thin.yml),
51
+ user: 'user', group: 'group'
52
+ )
53
+ subject
54
+ expect(pre_scripts).to eq({
55
+ mkdir_run: 'mkdir -p /var/run/test',
56
+ chown_run: 'chown user:group /var/run/test'
57
+ })
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cany::Recipes::Unicorn do
4
+ let(:setup) { proc { use :unicorn } }
5
+ let(:spec) do
6
+ Cany::Specification.new do
7
+ name 'test'
8
+ end
9
+ end
10
+ let(:recipe) { spec.recipes.first }
11
+ let(:system_recipe) { Cany::Dpkg::DebHelperRecipe.new(spec) }
12
+ let(:pre_scripts) { system_recipe.option(:service_pre_scripts) }
13
+ subject { recipe.binary }
14
+
15
+ context '#binary' do
16
+ before do
17
+ spec.setup &setup
18
+ spec.system_recipe = system_recipe
19
+ recipe.inner = double('recipe')
20
+ expect(recipe.inner).to receive(:binary)
21
+ end
22
+
23
+ context 'without configuration' do
24
+
25
+ it 'should launch unicorn only with environment specification and config file' do
26
+ expect(recipe).to receive(:install_service).with(
27
+ :unicorn,
28
+ %w(/usr/bin/test unicorn --config-file /etc/test/unicorn.rb --env production),
29
+ user: 'www-data', group: 'www-data'
30
+ )
31
+ subject
32
+ expect(pre_scripts).to eq({
33
+ mkdir_run: 'mkdir -p /var/run/test',
34
+ chown_run: 'chown www-data:www-data /var/run/test'
35
+ })
36
+ end
37
+ end
38
+
39
+ context 'with defined user/group' do
40
+ let(:setup) { proc { use(:unicorn) { user 'user'; group 'group' } } }
41
+
42
+ it 'should launch unicorn with as this user and group' do
43
+ expect(recipe).to receive(:install_service).with(
44
+ :unicorn,
45
+ %w(/usr/bin/test unicorn --config-file /etc/test/unicorn.rb --env production),
46
+ user: 'user', group: 'group'
47
+ )
48
+ subject
49
+ expect(pre_scripts).to eq({
50
+ mkdir_run: 'mkdir -p /var/run/test',
51
+ chown_run: 'chown user:group /var/run/test'
52
+ })
53
+ end
54
+ end
55
+ end
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cany
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Malte Swart
@@ -99,6 +99,8 @@ files:
99
99
  - spec/cany/recipes/bundler_spec.rb
100
100
  - spec/cany/recipes/rails_spec.rb
101
101
  - spec/cany/recipes/sidekiq_spec.rb
102
+ - spec/cany/recipes/thin_spec.rb
103
+ - spec/cany/recipes/unicorn_spec.rb
102
104
  - spec/cany/specification_spec.rb
103
105
  - spec/cany_spec.rb
104
106
  - spec/fixtures/multiple/one.canspec
@@ -141,6 +143,8 @@ test_files:
141
143
  - spec/cany/recipes/bundler_spec.rb
142
144
  - spec/cany/recipes/rails_spec.rb
143
145
  - spec/cany/recipes/sidekiq_spec.rb
146
+ - spec/cany/recipes/thin_spec.rb
147
+ - spec/cany/recipes/unicorn_spec.rb
144
148
  - spec/cany/specification_spec.rb
145
149
  - spec/cany_spec.rb
146
150
  - spec/fixtures/multiple/one.canspec