Skip to content

Commit

Permalink
Merge pull request #7 from EncoreTechnologies/release/v0.12.2
Browse files Browse the repository at this point in the history
Fixed a bug in  that wasn't properly checking registry key didn't exist.
  • Loading branch information
nmaludy authored Jun 25, 2020
2 parents 556fc27 + b0057f3 commit 7890f1b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## Development

## 2020-06-25 - Release v0.12.2

- Fixed a bug in `fluentd_windows_service` that wasn't properly checking registry key didn't exist.

Contributed by Nick Maludy (@nmaludy)


## 2020-06-25 - Release v0.12.1

- Fixed a bug in `fluentd_windows_service` that wasn't properly checking exception messages when the fluentd service didn't exist.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# class to create the FluentD service on Windows
class Puppet::Provider::FluentdWindowsService::FluentdWindowsService
def initialize
@service_doesnt_exit_error = 'The specified service does not exist as an installed service.'
@service_doesnt_exit_error = 'The specified service does not exist as an installed service'
@regex_service_name = Regexp.new(%r{SERVICE_NAME:\s*(.*)\s*})
@regex_display_name = Regexp.new(%r{\s*DISPLAY_NAME\s*:\s*(.*)\s*})
@regex_description = Regexp.new(%r{DESCRIPTION:\s*(.*)\s*})
Expand Down Expand Up @@ -70,14 +70,18 @@ def service_instance(_context, service)
end

# the fluentdopt options are stored in the registry
Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\#{service}", Win32::Registry::KEY_ALL_ACCESS) do |reg|
instance[:fluentdopt] = reg['fluentdopt']
begin
Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\#{service}") do |reg|
instance[:fluentdopt] = reg['fluentdopt']
end
rescue Win32::Registry::Error # rubocop:disable Lint/HandleExceptions
# this happens of the key above doesn't exist
end

instance
end

def create(context, name, should, noop)
arguments = []
arguments += ['--reg-winsvc', 'i'] # 'i' stands for install
arguments += ['--winsvc-name', should[:name]]
if should[:display_name]
Expand All @@ -95,7 +99,7 @@ def create(context, name, should, noop)
context.info("fluentd_windows_service[#{name}] would have run: #{should[:command]} #{arguments.join(' ')}")
else
# create the service
commad(should[:command], arguments)
command(should[:command], arguments)
end
end

Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "encore-fluentd",
"version": "0.12.1",
"version": "0.12.2",
"author": "encore",
"summary": "Installs, configures, and manages Fluentd data collector",
"license": "Apache-2.0",
Expand Down

0 comments on commit 7890f1b

Please sign in to comment.