Skip to content

Instantly share code, notes, and snippets.

@holyjak
Created July 29, 2015 08:10
Show Gist options
  • Save holyjak/a73291e696eb3f873cb2 to your computer and use it in GitHub Desktop.
Save holyjak/a73291e696eb3f873cb2 to your computer and use it in GitHub Desktop.
Fixing a mysterious .ebextensions command time out (AWS Elastic Beanstalk)
files:
/opt/gor:
source: "https://s3-eu-west-1.amazonaws.com/elasticbeanstalk-eu-west-1-<our-id>/our_fileserver/gor"
authentication: S3Access
mode: "000755"
owner: root
group: root
# Script to start Gor in the background
# Beware: We need to intercept port 8080 b/c 80 is redirected there via iptables
/opt/gor-in-background:
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
pidof /opt/gor || nohup /opt/gor --input-raw :8080 --output-http 'https://our-staging-server|1' >/dev/null 2>&1 </dev/null &
# Only container_commands can access env variables configured in EB (ENV)
# Start gor, limit it to copy max 1 req / sec
container_commands:
"Start Gor on Prod leader":
command: test "$ENV" = "production" && /opt/gor-in-background >/dev/null 2>&1 # ! w/o the redirect it will time-out
leader_only: true
ignoreErrors: true # returns an "error" when not in Prod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment