From 1850735757e47ef0451f311b131402af975b75ab Mon Sep 17 00:00:00 2001 From: Binbin Lu Date: Mon, 16 Nov 2015 22:50:29 -0800 Subject: [PATCH] remove version directory from config file --- conf/codedeployagent.yml | 1 - .../lib/aws/plugins/deploy_agent_version.rb | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/conf/codedeployagent.yml b/conf/codedeployagent.yml index ad2aef07..ca6fdfe1 100644 --- a/conf/codedeployagent.yml +++ b/conf/codedeployagent.yml @@ -5,6 +5,5 @@ :program_name: codedeploy-agent :root_dir: '/opt/codedeploy-agent/deployment-root' :verbose: false -:version_dir: '/opt/codedeploy-agent/' :wait_between_runs: 1 :proxy_uri: \ No newline at end of file diff --git a/vendor/gems/codedeploy-commands-1.0.0/lib/aws/plugins/deploy_agent_version.rb b/vendor/gems/codedeploy-commands-1.0.0/lib/aws/plugins/deploy_agent_version.rb index e06ad9ab..87b394e5 100644 --- a/vendor/gems/codedeploy-commands-1.0.0/lib/aws/plugins/deploy_agent_version.rb +++ b/vendor/gems/codedeploy-commands-1.0.0/lib/aws/plugins/deploy_agent_version.rb @@ -4,12 +4,12 @@ class DeployAgentVersion < Seahorse::Client::Plugin class Handler < Seahorse::Client::Handler def initialize(handler = nil) @handler = handler - file_path = File.join(ProcessManager::Config.config[:version_dir], '.version') + file_path = get_version_tracking_file if File.exist?(file_path) @agent_version ||= File.read(file_path).split(': ').last.strip else @agent_version ||= "UNKNOWN_VERSION" - log(:warn, "Version tracking file doesn't exist in directory #{file_path}") + log(:warn, "Version tracking file either does not exist or cannot be read.") end end @@ -17,6 +17,15 @@ 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)