aws / aws-codedeploy-agent

Host Agent for AWS CodeDeploy
https://aws.amazon.com/codedeploy
Apache License 2.0
329 stars 187 forks source link

codedeploy-agent stop service #55

Closed vasanthperiyasamy closed 6 years ago

vasanthperiyasamy commented 8 years ago

Stopping the codedeploy-agent service doesn't kill the CodeDeployPlugin::CommandPoller immediately and the command takes about 2 minutes to execute.

Just wondering if there is a way to cleanly stop the agent service without using kill/pkill?

[root@cli-2-0-8 ec2-user]# service codedeploy-agent status
error: No AWS CodeDeploy agent running

[root@cli-2-0-8 ec2-user]# time service codedeploy-agent start
Starting codedeploy-agent:
real    0m0.262s
user    0m0.240s
sys 0m0.004s

[root@cli-2-0-8 ec2-user]# ps aux | grep codedeploy 
root      7967  0.0  1.9 215532 19640 pts/0    Sl   04:34   0:00 codedeploy-agent: master 7967                                    
root      7971  2.8  2.9 294460 30376 pts/0    Sl   04:34   0:00 codedeploy-agent: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller of master 7967
root      7983  0.0  0.2 110460  2276 pts/0    S+   04:34   0:00 grep --color=auto codedeploy

[root@cli-2-0-8 ec2-user]# service codedeploy-agent status
The AWS CodeDeploy agent is running as PID 7967

[root@cli-2-0-8 ec2-user]# time service codedeploy-agent stop
Stopping codedeploy-agent:
real    1m20.242s
user    0m0.220s
sys 0m0.012s

[root@cli-2-0-8 ec2-user]# service codedeploy-agent status
Pidfile /opt/codedeploy-agent/state/.pid/codedeploy-agent.pid present but no matching process running - cleaning up
error: No AWS CodeDeploy agent running

[root@cli-2-0-8 ec2-user]# ps aux | grep codedeploy 
root      7971  0.1  3.0 360576 30796 pts/0    Sl   04:34   0:00 codedeploy-agent: InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller of master 7967 - shutting down
root      8109  0.0  0.2 110456  2132 pts/0    S+   04:36   0:00 grep --color=auto codedeploy
yubangxi commented 8 years ago

Hi,

When you stop CodeDeploy agent using Stop command , the host agent will try to finish job (like lifecycle event) currently it's still working on before exits. The agent tries to make the shutdown gracefully so that it won't put any deployment in a bad and non-recoverable state.