poise-service 1.0.1 → 1.0.2
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +4 -5
- data/chef/templates/{systemd.service.erb → default/systemd.service.erb} +0 -0
- data/chef/templates/{sysvinit.sh.erb → default/sysvinit.sh.erb} +0 -0
- data/chef/templates/{upstart.conf.erb → default/upstart.conf.erb} +0 -0
- data/lib/poise_service/resources.rb +0 -1
- data/lib/poise_service/resources/poise_service_user.rb +2 -0
- data/lib/poise_service/service_providers/base.rb +1 -1
- data/lib/poise_service/service_providers/dummy.rb +14 -2
- data/lib/poise_service/service_providers/sysvinit.rb +1 -1
- data/lib/poise_service/version.rb +1 -1
- data/test/cookbooks/poise-service_test/recipes/default.rb +2 -0
- data/test/integration/default/serverspec/default_spec.rb +3 -3
- data/test/spec/resources/poise_service_spec.rb +2 -2
- data/test/spec/service_mixin_spec.rb +2 -2
- data/test/spec/service_providers/dummy_spec.rb +3 -3
- data/test/spec/service_providers/sysvinit_spec.rb +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3fc72bef39422fae1951da15292b19f8197a71b
|
4
|
+
data.tar.gz: 2aa9c8a1eb8d6808b0e591ff8a2aabfdc3360ad3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
-
* `
|
194
|
-
* `for_provider` – Provider to set options for.
|
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
|
|
File without changes
|
File without changes
|
File without changes
|
@@ -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.
|
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
|
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.
|
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.
|
@@ -28,15 +28,15 @@ describe 'default provider' do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
describe 'sysvinit provider', unless: File.
|
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.
|
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.
|
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(:
|
183
|
-
allow(File).to receive(:
|
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
|
-
|
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
|
-
|
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(:
|
26
|
-
allow(File).to receive(:
|
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(:
|
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(:
|
89
|
-
allow(File).to receive(:
|
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.
|
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-
|
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.
|
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.
|