I have an AWS Elastic Beanstalk setup with some .ebextensions
files with some container_commands
in them. One of those commands is a script. The script completes, but the next command doesn't run.
$ pstree -p | grep cfn-
|-cfn-hup(2833)-+-command-process(10161)---command-process(10162)-+-cfn-init(10317)---bash(10428)
$ ps 10317
PID TTY STAT TIME COMMAND
10317 ? S 0:00 /usr/bin/python2.7 /opt/aws/bin/cfn-init -s arn:aws:cloudformation:us-east-1:278460835609:stack/awseb-e-4qwsypzv7u-stack/f8ab55f0-393c-11e9-8907-0ae8cc519968 -r AWSEBAutoScalingGroup --region us-east-1 --configsets Infra-EmbeddedPostBuild
$ ps 10428
PID TTY STAT TIME COMMAND
10428 ? Z 0:00 [bash] <defunct>
As you can see, my script is a defuct zombie, but cfn-init
isn't making a wait(2) syscall for it.
When I run the script from the command line, it terminates properly.
I have to assume cfn-init
is getting SIGCHLD
. Why isn't it wait(2)ing and moving on?
Also, is there a better way to investigate this? I've been looking at running processes and reading the completely unhelpful /var/log/eb-*
logs.
FWIW, the script is very simple:
#!/usr/bin/env bash
mkfifo ~ec2-user/fifo
nohup ~ec2-user/holdlock.sh &
read < ~ec2-user/fifo
And the thing it nohups is pretty simple:
#!/usr/bin/env bash
(echo 'select pg_advisory_lock(43110);';sleep 10m) |
PGPASSWORD=$RDS_PASSWORD psql -h $RDS_HOSTNAME -d $RDS_DB_NAME -U
$RDS_USERNAME | tee ~ec2-user/nhlog > ~ec2-user/fifo