I am running my web server on Elastic Beanstalk, and using Papertrail for logging. I am using the official .ebextensions script to get papertrail set up during deployment, but I have a problem. I use environment variables as part of my hostname used as the sender when remote_syslog uploads logs to papertrail, and while this works fine during deployment, when the 01_set_logger_hostname
container command is triggered, I run into problems whenever I change environment variables by modifying the environment's configuration, since it seems an eb config
call will only restart the application server, not run any of the scripts run during deployment, including the ebextensions container commands.
"/tmp/set-logger-hostname.sh":
mode: "00555"
owner: root
group: root
encoding: plain
content: |
#!/bin/bash
logger_config="/etc/log_files.yml"
appname=`{ "Ref" : "AWSEBEnvironmentName" }`
instid=`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`
myhostname=${SOME_VARIABLE}_${appname}_${instid}
if [ -f $logger_config ]; then
# Sub the hostname
sed "s/hostname:.*/hostname: $myhostname/" -i $logger_config
fi
As you can see, since my hostname depends on ${SOME_VARIABLE}
, I need to refresh the hostname whenever ${SOME_VARIABLE}
is modified following eb config
.
Is there a way to trigger a script to be run whenever an eb config
command is run, so that I can not only restart my web application but also reconfigure and restart remote_syslog
with the updated hostname?
.platform/hooks/prebuild/env.sh
and it now runs on AWS console config changes. I chose prebuild because it runs right after download and extraction of the app which was the ideal time for my use case. – Arsenide