poise-service 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19ac4e7234269bdbef35c490936ccf490ac35617
4
- data.tar.gz: 142369bfa25095a9f383fb011608481fc861a6d8
3
+ metadata.gz: f3fc72bef39422fae1951da15292b19f8197a71b
4
+ data.tar.gz: 2aa9c8a1eb8d6808b0e591ff8a2aabfdc3360ad3
5
5
  SHA512:
6
- metadata.gz: 6da85709d79589eb70e2e3483473cce141231f1b836ff8a6e45b172386360f79ec1c1eda1a60978a6938ddb99c7667d4127bcd8e5f9efd8048dcaeb125827070
7
- data.tar.gz: e389aa918481ec598c1cbcac9bbbff271945b635809eb849fa869642c01c51fce643067555f7597ffe01b264c8f86541c896a08c6f95aacf665a3c15aff9cec9
6
+ metadata.gz: 84418165ab96792da66819398e11360890259d764e2f9ecfe93ac1ce85d9e0b176d44b66e3a20cb66da20f1a6f40535910e864f83e26eec76f60f037a1f7c510
7
+ data.tar.gz: e4aea2a2c486514982693e15d3d3e1d8e5d71bebce16366c45587e3fc9cbb374d95d13b8d61e26495cd34b3339de41a13f8dbaccc9ab15e1e9951577fd9a5345
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.0.2
4
+ * Fix a potential infinite loop when starting a service with the dummy provider.
5
+ * [#2](https://github.com/poise/poise-service/pull/2) Remove usage of root
6
+ default files so uploading with Berkshelf works (for now).
7
+
3
8
  ## v1.0.1
4
9
 
5
10
  * Don't use a shared, mutable default value for `#environment`.
data/README.md CHANGED
@@ -125,7 +125,7 @@ that are passed down to the service provider and can be used to control how it
125
125
  creates and manages the service. These can be set in the `poise_service`
126
126
  resource using the `options` method, in node attributes or via the
127
127
  `poise_service_options` resource. The options from all sources are merged
128
- together into a single hash based.
128
+ together in to a single hash.
129
129
 
130
130
  When setting options in the resource you can either set them for all providers:
131
131
 
@@ -167,7 +167,7 @@ poise_service_options 'myapp' do
167
167
  end
168
168
  ```
169
169
 
170
- Unlike resource attributes, service options can be different for each provide.
170
+ Unlike resource attributes, service options can be different for each provider.
171
171
  Not all providers support the same options so make sure to the check the
172
172
  documentation for each provider to see what options the use.
173
173
 
@@ -190,9 +190,8 @@ end
190
190
 
191
191
  #### Attributes
192
192
 
193
- * `service_name` – Name of the service. *(name attribute)*
194
- * `for_provider` – Provider to set options for. If set, the resource must be
195
- defined and reachable before the `poise_service_options` resource.
193
+ * `resource` – Name of the service. *(name attribute)*
194
+ * `for_provider` – Provider to set options for.
196
195
 
197
196
  All other attribute keys will be used as options data.
198
197
 
@@ -15,7 +15,6 @@
15
15
  #
16
16
 
17
17
  require 'poise_service/resources/poise_service'
18
- require 'poise_service/resources/poise_service_test'
19
18
  require 'poise_service/resources/poise_service_user'
20
19
 
21
20
 
@@ -22,6 +22,7 @@ require 'poise'
22
22
  module PoiseService
23
23
  module Resources
24
24
  # (see PoiseServiceUser::Resource)
25
+ # @since 1.0.0
25
26
  module PoiseServiceUser
26
27
  # A `poise_service_user` resource to create service users/groups.
27
28
  #
@@ -67,6 +68,7 @@ module PoiseService
67
68
 
68
69
  # Provider for `poise_service_user`.
69
70
  #
71
+ # @since 1.0.0
70
72
  # @see Resource
71
73
  # @provides poise_service_user
72
74
  class Provider < Chef::Provider
@@ -180,7 +180,7 @@ module PoiseService
180
180
  # Don't trigger a restart if the template doesn't already exist, this
181
181
  # prevents restarting on the run that first creates the service.
182
182
  restart_on_update = options.fetch('restart_on_update', new_resource.restart_on_update)
183
- if restart_on_update && ::File.exists?(path)
183
+ if restart_on_update && ::File.exist?(path)
184
184
  mode = restart_on_update.to_s == 'immediately' ? :immediately : :delayed
185
185
  notifies :restart, new_resource, mode
186
186
  end
@@ -24,25 +24,37 @@ module PoiseService
24
24
 
25
25
  def action_start
26
26
  return if pid
27
+ Chef::Log.debug("[#{new_resource}] Starting #{new_resource.command}")
28
+ # Clear the pid file if it exists.
29
+ ::File.unlink(pid_file) if ::File.exist?(pid_file)
27
30
  if Process.fork
28
31
  # Parent, wait for the final child to write the pid file.
29
- until pid
32
+ until ::File.exist?(pid_file)
30
33
  sleep(1)
34
+ Chef::Log.debug("[#{new_resource}] Waiting for PID file")
31
35
  end
32
36
  else
33
37
  # :nocov:
38
+ Chef::Log.debug("[#{new_resource}] Forked")
34
39
  # First child, daemonize and go to town.
35
40
  Process.daemon(true)
41
+ Chef::Log.debug("[#{new_resource}] Daemonized")
36
42
  # Daemonized, set up process environment.
37
43
  Dir.chdir(new_resource.directory)
44
+ Chef::Log.debug("[#{new_resource}] Directory changed to #{new_resource.directory}")
38
45
  new_resource.environment.each do |key, val|
39
46
  ENV[key.to_s] = val.to_s
40
47
  end
41
48
  Process.uid = new_resource.user
49
+ Chef::Log.debug("[#{new_resource}] Process environment configured")
42
50
  IO.write(pid_file, Process.pid)
51
+ Chef::Log.debug("[#{new_resource}] PID written to #{pid_file}, execing #{new_resource.command}")
43
52
  Kernel.exec(new_resource.command)
53
+ # Just in case, bail out.
54
+ exit!
44
55
  # :nocov:
45
56
  end
57
+ Chef::Log.debug("[#{new_resource}] Started.")
46
58
  end
47
59
 
48
60
  def action_stop
@@ -61,7 +73,7 @@ module PoiseService
61
73
  end
62
74
 
63
75
  def pid
64
- return nil unless ::File.exists?(pid_file)
76
+ return nil unless ::File.exist?(pid_file)
65
77
  pid = IO.read(pid_file).to_i
66
78
  begin
67
79
  # Check if the PID is running.
@@ -27,7 +27,7 @@ module PoiseService
27
27
  end
28
28
 
29
29
  def pid
30
- IO.read(pid_file).to_i if ::File.exists?(pid_file)
30
+ IO.read(pid_file).to_i if ::File.exist?(pid_file)
31
31
  end
32
32
 
33
33
  private
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module PoiseService
19
- VERSION = '1.0.1'
19
+ VERSION = '1.0.2'
20
20
  end
@@ -14,6 +14,8 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
+ require 'poise_service/resources/poise_service_test'
18
+
17
19
  # Create the various services.
18
20
  poise_service_test 'default' do
19
21
  base_port 5000
@@ -28,15 +28,15 @@ describe 'default provider' do
28
28
  end
29
29
  end
30
30
 
31
- describe 'sysvinit provider', unless: File.exists?('/no_sysvinit') do
31
+ describe 'sysvinit provider', unless: File.exist?('/no_sysvinit') do
32
32
  it_should_behave_like 'a poise_service_test', 'sysvinit', 6000
33
33
  end
34
34
 
35
- describe 'upstart provider', unless: File.exists?('/no_upstart') do
35
+ describe 'upstart provider', unless: File.exist?('/no_upstart') do
36
36
  it_should_behave_like 'a poise_service_test', 'upstart', 7000, !old_upstart
37
37
  end
38
38
 
39
- describe 'systemd provider', unless: File.exists?('/no_systemd') do
39
+ describe 'systemd provider', unless: File.exist?('/no_systemd') do
40
40
  it_should_behave_like 'a poise_service_test', 'systemd', 8000
41
41
  end
42
42
 
@@ -179,8 +179,8 @@ describe PoiseService::Resources::PoiseService::Resource do
179
179
  service_provider('sysvinit')
180
180
  step_into(:poise_service)
181
181
  before do
182
- allow(File).to receive(:exists?).and_call_original
183
- allow(File).to receive(:exists?).with('/etc/init.d/test').and_return(true)
182
+ allow(File).to receive(:exist?).and_call_original
183
+ allow(File).to receive(:exist?).with('/etc/init.d/test').and_return(true)
184
184
  end
185
185
  subject { chef_run.template('/etc/init.d/test') }
186
186
 
@@ -49,7 +49,7 @@ describe PoiseService::ServiceMixin::Resource do
49
49
  include PoiseService::ServiceMixin::Resource
50
50
  end
51
51
 
52
- its(:action) { is_expected.to eq :doit }
52
+ it { expect(Array(subject.action)).to eq %i{doit} }
53
53
  its(:allowed_actions) { is_expected.to eq %i{nothing doit enable disable start stop restart reload} }
54
54
  its(:service_name) { is_expected.to eq 'test' }
55
55
  end # /context with Poise already included
@@ -60,7 +60,7 @@ describe PoiseService::ServiceMixin::Resource do
60
60
  actions(:doit)
61
61
  end
62
62
 
63
- its(:action) { is_expected.to eq :enable }
63
+ it { expect(Array(subject.action)).to eq %i{enable} }
64
64
  its(:allowed_actions) { is_expected.to eq %i{nothing enable disable start stop restart reload doit} }
65
65
  its(:service_name) { is_expected.to eq 'test' }
66
66
  end # /context without Poise already included
@@ -22,15 +22,15 @@ describe PoiseService::ServiceProviders::Dummy do
22
22
  before do
23
23
  allow(Process).to receive(:fork).and_return(0)
24
24
  allow(Process).to receive(:kill).with(0, 100)
25
- allow(File).to receive(:exists?).and_call_original
26
- allow(File).to receive(:exists?).with('/var/run/test.pid').and_return(true)
25
+ allow(File).to receive(:exist?).and_call_original
26
+ allow(File).to receive(:exist?).with('/var/run/test.pid').and_return(true)
27
27
  allow(IO).to receive(:read).and_call_original
28
28
  allow(IO).to receive(:read).with('/var/run/test.pid').and_return('100')
29
29
  end
30
30
 
31
31
  describe '#action_enable' do
32
32
  before do
33
- allow(File).to receive(:exists?).with('/var/run/test.pid').and_return(false, false, true)
33
+ allow(File).to receive(:exist?).with('/var/run/test.pid').and_return(false, false, false, true)
34
34
  expect_any_instance_of(described_class).to receive(:sleep).with(1).once
35
35
  end
36
36
  recipe do
@@ -85,8 +85,8 @@ EOH
85
85
  describe '#pid' do
86
86
  subject { described_class.new(nil, nil) }
87
87
  before do
88
- allow(File).to receive(:exists?).and_call_original
89
- allow(File).to receive(:exists?).with('/pid').and_return(true)
88
+ allow(File).to receive(:exist?).and_call_original
89
+ allow(File).to receive(:exist?).with('/pid').and_return(true)
90
90
  allow(IO).to receive(:read).and_call_original
91
91
  allow(IO).to receive(:read).with('/pid').and_return('100')
92
92
  expect(subject).to receive(:pid_file).and_return('/pid').at_least(:once)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poise-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Kantrowitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-23 00:00:00.000000000 Z
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: halite
@@ -85,9 +85,9 @@ files:
85
85
  - README.md
86
86
  - Rakefile
87
87
  - chef/attributes/default.rb
88
- - chef/templates/systemd.service.erb
89
- - chef/templates/sysvinit.sh.erb
90
- - chef/templates/upstart.conf.erb
88
+ - chef/templates/default/systemd.service.erb
89
+ - chef/templates/default/sysvinit.sh.erb
90
+ - chef/templates/default/upstart.conf.erb
91
91
  - lib/poise_service.rb
92
92
  - lib/poise_service/cheftie.rb
93
93
  - lib/poise_service/error.rb
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.4.5
148
+ rubygems_version: 2.4.8
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: A Chef cookbook for managing system services.