Skip to content

Commit

Permalink
Merge pull request #1483 from fluent/fix-cleanup-resource
Browse files Browse the repository at this point in the history
Fix cleanup resource
  • Loading branch information
repeatedly authored Mar 2, 2017
2 parents 0886030 + 475ed45 commit 065a063
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/fluent/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
# limitations under the License.
#

require 'serverengine/utils'

module Fluent
DEFAULT_CONFIG_PATH = ENV['FLUENT_CONF'] || '/etc/fluent/fluent.conf'
DEFAULT_PLUGIN_DIR = ENV['FLUENT_PLUGIN'] || '/etc/fluent/plugin'
DEFAULT_SOCKET_PATH = ENV['FLUENT_SOCKET'] || '/var/run/fluent/fluent.sock'
DEFAULT_OJ_OPTIONS = {bigdecimal_load: :float, mode: :compat, use_to_json: true}
IS_WINDOWS = /mswin|mingw/ === RUBY_PLATFORM
private_constant :IS_WINDOWS

def self.windows?
IS_WINDOWS
ServerEngine.windows?
end
end
10 changes: 10 additions & 0 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def before_run

def after_run
stop_rpc_server if @rpc_endpoint
Fluent::Supervisor.cleanup_resources
end

def run_rpc_server
Expand Down Expand Up @@ -387,6 +388,14 @@ def self.default_options
}
end

def self.cleanup_resources
unless Fluent.windows?
if ENV.has_key?('SERVERENGINE_SOCKETMANAGER_PATH')
FileUtils.rm_f(ENV['SERVERENGINE_SOCKETMANAGER_PATH'])
end
end
end

def initialize(opt)
@daemonize = opt[:daemonize]
@supervise = opt[:supervise]
Expand Down Expand Up @@ -493,6 +502,7 @@ def run_worker
init_engine
run_configure
run_engine
self.class.cleanup_resources if @standalone_worker
exit 0
end
end
Expand Down

0 comments on commit 065a063

Please sign in to comment.