Skip to content

Commit 87e07cc

Browse files
committed
Adding preliminary macOS support
This changeset adds a launchd entrypoint and the corresponding launchd plist file. This makes it easier to run the CodeDeploy agent under macOS since launchd doesn't really support disconnected daemons.
1 parent 247c7e8 commit 87e07cc

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

bin/codedeploy-launchd

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
# Run the CodeDeploy agent in the foreground so that it
5+
# can be controlled by MacOS's launchd. This does away with
6+
# most of the Gli command-line handling stuff, since this has
7+
# only one way of being invoked (i.e. launchd).
8+
#
9+
# Mostly copied from the official CLI entrypoint in `lib/codedeploy-agent.rb`
10+
agent_dir = '/opt/aws/codedeploy'
11+
$LOAD_PATH.unshift "#{agent_dir}/lib"
12+
13+
require 'instance_agent'
14+
15+
# Always use the config file from the installation root:
16+
InstanceAgent::Config.config(
17+
config_file: "#{agent_dir}/conf/codedeployagent.yml"
18+
)
19+
20+
InstanceAgent::Platform.util = InstanceAgent::LinuxUtil
21+
InstanceAgent::Config.load_config
22+
23+
# The `.new` here ensures that the master runs in the foreground instead of as
24+
# a daemon.
25+
InstanceAgent::Runner::Master.new.start
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>Label</key>
6+
<string>com.amazon.aws.codedeploy</string>
7+
<key>UserName</key>
8+
<string>root</string>
9+
<key>RunAtLoad</key>
10+
<true/>
11+
<key>ProgramArguments</key>
12+
<array>
13+
<string>/opt/aws/codedeploy/bin/codedeploy-launchd</string>
14+
</array>
15+
<key>KeepAlive</key>
16+
<true/>
17+
</dict>
18+
</plist>

0 commit comments

Comments
 (0)