Skip to content

Commit eef9a73

Browse files
author
Gao Han
committed
Passing args properly, removing redundant execs and renaming wrapper for codedeploy-agent
1 parent 9bb4d2c commit eef9a73

File tree

4 files changed

+29
-24
lines changed

4 files changed

+29
-24
lines changed

bin/codedeploy-agent-wrapper

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env ruby
2+
3+
ruby_versions = ["2.3", "2.2", "2.1", "2.0"]
4+
actual_ruby_version = RUBY_VERSION.split('.').map{|s|s.to_i}
5+
left_bound = '2.0.0'.split('.').map{|s|s.to_i}
6+
right_bound = '2.3.1'.split('.').map{|s|s.to_i}
7+
ruby_bin = nil
8+
9+
if (actual_ruby_version <=> left_bound) > -1 && (actual_ruby_version <=> right_bound) < 1
10+
ruby_bin = "ruby"
11+
else
12+
ruby_versions.each do |i|
13+
ruby_dir = "/usr/bin/ruby#{i}"
14+
if File.file?(ruby_dir)
15+
ruby_bin = ruby_dir
16+
break
17+
end
18+
end
19+
end
20+
21+
if ruby_bin
22+
exec("#{ruby_bin} #{File.join(File.expand_path(File.dirname(__FILE__)), "/codedeploy-agent")} #{ARGV.join(' ')}")
23+
end
24+
25+
STDERR.puts "No supported ruby version found. Code Deploy Host Agent supports Ruby version of 2.0.x to 2.3.x."
26+
exit(1)

bin/start-wrapper

Lines changed: 0 additions & 21 deletions
This file was deleted.

init.d/codedeploy-agent

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ prog="codedeploy-agent"
2727
USER=""
2828
AGENT_ROOT="/opt/codedeploy-agent/"
2929
INSTALLER="/opt/codedeploy-agent/bin/install"
30-
BIN="/opt/codedeploy-agent/bin/start-wrapper"
30+
BIN="/opt/codedeploy-agent/bin/codedeploy-agent-wrapper"
3131

3232
start() {
3333
echo -n $"Starting $prog:"

init.d/codedeploy-agent.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Description=AWS CodeDeploy Host Agent
33

44
[Service]
55
Type=forking
6-
ExecStart=/bin/sh -a -c '[ -f /etc/profile ] && source /etc/profile; /opt/codedeploy-agent/bin/start-wrapper start'
7-
ExecStop=/opt/codedeploy-agent/bin/start-wrapper stop
6+
ExecStart=/bin/sh -a -c '[ -f /etc/profile ] && source /etc/profile; /opt/codedeploy-agent/bin/codedeploy-agent-wrapper start'
7+
ExecStop=/opt/codedeploy-agent/bin/codedeploy-agent-wrapper stop
88
RemainAfterExit=no
99
# Comment out the following line to run the agent as the codedeploy user
1010
# Note: The user must first exist on the system

0 commit comments

Comments
 (0)