aws / aws-codedeploy-agent

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

Hangs on process that forks and exits. #26

Closed mariusnita closed 9 years ago

mariusnita commented 9 years ago

I have a program like this:

#!/usr/bin/env python
import sys
import os
pid = os.fork()
if pid > 0:
  sys.exit(0)
command_that_runs_forever()

If I use this script as my ApplicationStart command, the code deploy agent will hang forever in the application start stage. I don't understand why this would happen. When I run the program from the command line, it returns immediately (the child being forked, and parent exiting immediately) and the status code is 0.

Any light shed on this would be appreciated. Thanks!

suryanarayanan commented 9 years ago

Hi,

Your processes should relinquish handles to stdin, stdout and stderr. Please see https://github.com/aws/aws-codedeploy-agent/blob/master/lib/instance_agent/plugins/codedeploy/hook_executor.rb#L141 could be why the agent hangs on your script. Here's how you solve it http://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting.html#troubleshooting-long-running-processes