Skip to content

Commit

Permalink
Fixed an edge case, & changed default nssm parameters
Browse files Browse the repository at this point in the history
Added exit code 1 as an acceptable return code within
`nssm_service_installed?`. If AppRotateOnline is not set
for nssm, it will only rotate the logs when the service
is restarted. Changed the default nssm parameters so
that logs are rotated when they reach 20 MB in size.
  • Loading branch information
Ginja committed Jan 19, 2016
1 parent 3b8ce6c commit 478a2e8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions attributes/default.rb
Expand Up @@ -47,8 +47,9 @@
'AppDirectory' => join_path(data_prefix_path, 'data'),
'AppStdout' => join_path(config_prefix_path, 'stdout.log'),
'AppStderr' => join_path(config_prefix_path, 'error.log'),
'AppRotateSeconds' => 86_400,
'AppRotateFiles' => 1
'AppRotateFiles' => 1,
'AppRotateOnline' => 1,
'AppRotateBytes' => 20_000_000
}

default['consul']['checksums'] = {
Expand Down
2 changes: 1 addition & 1 deletion libraries/consul_service_linux.rb
Expand Up @@ -91,7 +91,7 @@ def action_disable
end

def service_options(service)
service.command(new_resource.command new_resource.config_file, new_resource.config_dir)
service.command(new_resource.command(new_resource.config_file, new_resource.config_dir))
service.directory(new_resource.data_dir)
service.user(new_resource.user)
service.environment(new_resource.environment)
Expand Down
6 changes: 4 additions & 2 deletions libraries/helpers.rb
Expand Up @@ -58,7 +58,7 @@ def correct_version?(executable, version)
end

def binary_checksum(item)
node['consul']['checksums'].fetch(binary_filename item)
node['consul']['checksums'].fetch(binary_filename(item))
end

def binary_filename(item)
Expand Down Expand Up @@ -127,7 +127,9 @@ def nssm_params
end

def nssm_service_installed?
exit_code = shell_out!(%{"#{nssm_exe}" status consul}, returns: [0, 3]).exitstatus
# 1 is command not found
# 3 is service not found
exit_code = shell_out!(%{"#{nssm_exe}" status consul}, returns: [0, 1, 3]).exitstatus
exit_code == 0 ? true : false
end

Expand Down

0 comments on commit 478a2e8

Please sign in to comment.