From 87e07ccfb33fcc9bc1614773575106ce1f79f071 Mon Sep 17 00:00:00 2001 From: Esteban Santana Santana Date: Fri, 23 Jul 2021 18:05:24 -0700 Subject: [PATCH] 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. --- bin/codedeploy-launchd | 25 +++++++++++++++++++++++++ init.d/com.amazon.aws.codedeploy.plist | 18 ++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 bin/codedeploy-launchd create mode 100644 init.d/com.amazon.aws.codedeploy.plist diff --git a/bin/codedeploy-launchd b/bin/codedeploy-launchd new file mode 100755 index 00000000..164eb28e --- /dev/null +++ b/bin/codedeploy-launchd @@ -0,0 +1,25 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# Run the CodeDeploy agent in the foreground so that it +# can be controlled by MacOS's launchd. This does away with +# most of the Gli command-line handling stuff, since this has +# only one way of being invoked (i.e. launchd). +# +# Mostly copied from the official CLI entrypoint in `lib/codedeploy-agent.rb` +agent_dir = '/opt/aws/codedeploy' +$LOAD_PATH.unshift "#{agent_dir}/lib" + +require 'instance_agent' + +# Always use the config file from the installation root: +InstanceAgent::Config.config( + config_file: "#{agent_dir}/conf/codedeployagent.yml" +) + +InstanceAgent::Platform.util = InstanceAgent::LinuxUtil +InstanceAgent::Config.load_config + +# The `.new` here ensures that the master runs in the foreground instead of as +# a daemon. +InstanceAgent::Runner::Master.new.start diff --git a/init.d/com.amazon.aws.codedeploy.plist b/init.d/com.amazon.aws.codedeploy.plist new file mode 100644 index 00000000..a13fe1ec --- /dev/null +++ b/init.d/com.amazon.aws.codedeploy.plist @@ -0,0 +1,18 @@ + + + + + Label + com.amazon.aws.codedeploy + UserName + root + RunAtLoad + + ProgramArguments + + /opt/aws/codedeploy/bin/codedeploy-launchd + + KeepAlive + + +