Skip to content

Instantly share code, notes, and snippets.

@glennpratt
Created June 21, 2016 21:35
Show Gist options
  • Save glennpratt/7e760c360c0c7e00b718097d709e2fe0 to your computer and use it in GitHub Desktop.
Save glennpratt/7e760c360c0c7e00b718097d709e2fe0 to your computer and use it in GitHub Desktop.
AWS CodeDeploy logger include.
# This sends all output from the command to journalctl while allowing CodeDeploy
# agent to capture it as well. It also prefixes the output with timestamps for
# better debugging via CodeDeploy logs.
#
# TODO Consider changing codedeploy-agent to do these things itself.
#
# NOTE Not POSIX compliant; must run in bash or bash masquerading as sh.
# TODO Figure out why codedeploy-agent (using Open3), isn't respecting the
# shebang to all our scripts which are /bin/bash. See:
# https://github.com/aws/aws-codedeploy-agent/issues/71
set +o posix
ISO_8601="%FT%TZ:"
exec 1> >(tee >(systemd-cat -t cloud-database-api:$(basename $0)) | ts "$ISO_8601")
exec 2> >(tee >(systemd-cat -t cloud-database-api:$(basename $0) -p err) | ts "$ISO_8601" >&2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment