Skip to content

Commit

Permalink
fix file path error
Browse files Browse the repository at this point in the history
  • Loading branch information
feverLu committed Nov 17, 2015
1 parent 1850735 commit 26ec83c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
4 changes: 4 additions & 0 deletions lib/instance_agent/platform/linux_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def self.extract_tgz(bundle_file, dst)
def self.supports_process_groups?()
true
end

def self.codedeploy_version_file
File.join(ProcessManager::Config.config[:root_dir], '..')
end

private
def self.execute_tar_command(cmd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,19 @@ class DeployAgentVersion < Seahorse::Client::Plugin
class Handler < Seahorse::Client::Handler
def initialize(handler = nil)
@handler = handler
file_path = get_version_tracking_file
file_path = File.expand_path(File.join(InstanceAgent::Platform.util.codedeploy_version_file, '.version'))
if File.exist?(file_path)
@agent_version ||= File.read(file_path).split(': ').last.strip
else
@agent_version ||= "UNKNOWN_VERSION"
log(:warn, "Version tracking file either does not exist or cannot be read.")
log(:warn, "Version tracking file either does not exist or cannot be read in #{file_path}.")
end
end

def call(context)
context.http_request.headers['x-amz-codedeploy-agent-version'] = @agent_version
@handler.call(context)
end

def get_version_tracking_file
version_dir = ProcessManager::Config.config[:root_dir]
if version_dir.eql? 'Amazon/CodeDeploy'
file_path = File.join(version_dir, '.version')
else
file_path = File.join(version_dir, '..', '.version')
end
end

private
def log(severity, message)
Expand Down

0 comments on commit 26ec83c

Please sign in to comment.