Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions init.d/codedeploy-agent
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
# the deployment artifacts on to this instance.
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

COMMAND=$1
RETVAL=0
[ -f /etc/profile ] && [ "`stat --format '%U %G' /etc/profile`" == "root root" ] && source /etc/profile

Expand All @@ -33,7 +31,7 @@ start() {
echo -n $"Starting $prog:"
cd $AGENT_ROOT
if [ $USER ]; then
daemon --user=$USER $BIN start >/dev/null </dev/null 2>&1 # Try to start the server
nohup sudo -i -u $USER $BIN start >/dev/null </dev/null 2>&1 # Try to start the server
else
nohup $BIN start >/dev/null </dev/null 2>&1 # Try to start the server
fi
Expand All @@ -44,7 +42,7 @@ stop() {
echo -n $"Stopping $prog:"
cd $AGENT_ROOT
if [ $USER ]; then
daemon --user=$USER $BIN stop >/dev/null </dev/null 2>&1 # Try to stop the server
nohup sudo -i -u $USER $BIN stop >/dev/null </dev/null 2>&1 # Try to stop the server
else
nohup $BIN stop >/dev/null </dev/null 2>&1 # Try to stop the server
fi
Expand All @@ -55,7 +53,7 @@ restart() {
echo -n $"Restarting $prog:"
cd $AGENT_ROOT
if [ $USER ]; then
daemon --user=$USER $BIN restart >/dev/null </dev/null 2>&1 # Try to restart the server
nohup sudo -i -u $USER $BIN restart >/dev/null </dev/null 2>&1 # Try to restart the server
else
nohup $BIN restart >/dev/null </dev/null 2>&1 # Try to restart the server
fi
Expand All @@ -65,7 +63,7 @@ restart() {
status() {
cd $AGENT_ROOT
if [ $USER ]; then
daemon --user=$USER $BIN status # Status of the server
sudo -i -u $USER $BIN status # Status of the server
else
$BIN status # Status of the server
fi
Expand All @@ -75,14 +73,10 @@ status() {
update() {
echo -n $"Updating $prog:"
cd $AGENT_ROOT
if [ $USER ]; then
daemon --user=$USER sudo $INSTALLER auto #Update the agent
else
$INSTALLER auto #Update the agent
fi
$INSTALLER auto #Update the agent
}

case "$1" in
case "$COMMAND" in
start)
start
;;
Expand Down
12 changes: 12 additions & 0 deletions init.d/codedeploy-agent.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=AWS CodeDeploy Host Agent

[Service]
Type=forking
ExecStart=/opt/codedeploy-agent/bin/codedeploy-agent start
ExecStop=/opt/codedeploy-agent/bin/codedeploy-agent stop
User=codedeploy
RemainAfterExit=no

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion lib/instance_agent/platform/linux_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.prepare_script_command(script, absolute_cmd_path)
# command as the code deploy agent user
absolute_cmd_path
end

def self.quit()
# Send kill signal to parent and exit
Process.kill('TERM', Process.ppid)
Expand Down
2 changes: 1 addition & 1 deletion lib/instance_agent/plugins/codedeploy/command_executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module InstanceAgent
module Plugins
module CodeDeployPlugin
ARCHIVES_TO_RETAIN = 5

class CommandExecutor
class << self
attr_reader :command_methods
Expand Down