Skip to content

Instantly share code, notes, and snippets.

@jgautsch
Created May 29, 2014 00:48
Show Gist options
  • Select an option

  • Save jgautsch/b1d48d75f060c8fd5f26 to your computer and use it in GitHub Desktop.

Select an option

Save jgautsch/b1d48d75f060c8fd5f26 to your computer and use it in GitHub Desktop.

Revisions

  1. jgautsch created this gist May 29, 2014.
    21 changes: 21 additions & 0 deletions 0001_fix_permissions.config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # Fixing permissions of packaged gems
    files:
    "/opt/elasticbeanstalk/hooks/appdeploy/pre/10_fixing_permission.sh":
    content: |
    #!/usr/bin/env bash

    # . /opt/elasticbeanstalk/containerfiles/envvars
    . /opt/elasticbeanstalk/support/envvars

    CACHE_GEM_DIR=$EB_CONFIG_APP_ONDECK/vendor/cache

    if [ -d $CACHE_GEM_DIR ]
    then
    chown -R webapp:webapp $CACHE_GEM_DIR
    echo "Modified the owner of $CACHE_GEM_DIR files"
    else
    echo "Nothing in $CACHE_GEM_DIR"
    fi

    true
    mode: "000755"
    42 changes: 42 additions & 0 deletions 0002_bundle_pack.config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    # Modified system bundle script to run 'bundle package'
    files:
    "/opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh":
    content: |
    #!/usr/bin/env bash

    . /opt/elasticbeanstalk/support/envvars
    set -xe

    cd $EB_CONFIG_APP_ONDECK
    if [ -f Gemfile ]; then
    echo "running 'bundle install' with Gemfile:"
    cat Gemfile

    bundle install

    if [ $? != 0 ]; then
    echo "ERROR: bundle install failed!"
    exit 1
    else
    echo "bundle install succeeded"
    fi
    else
    echo "no Gemfile found! Skipping bundle install stage!"
    fi

    if [ -f Gemfile.lock ]; then
    echo "encountered a Gemfile.lock, setting proper permissions"
    chown $EB_CONFIG_APP_USER:$EB_CONFIG_APP_USER Gemfile.lock
    else
    echo "no Gemfile.lock file found, so no permissions to set on it"
    fi

    if [ "$BUNDLE_DISABLE_SHARED_GEMS" = "1" ]; then
    cd $EB_CONFIG_APP_ONDECK;
    chown -R $EB_CONFIG_APP_USER:$EB_CONFIG_APP_USER ./$BUNDLE_PATH;

    echo "Modified the owner of '$BUNDLE_PATH' files";
    fi

    true
    mode: "000755"
    66 changes: 66 additions & 0 deletions 0003_sidekiq.config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,66 @@
    # Sidekiq interaction and startup script
    # Sidekiq interaction and startup script
    files:
    "/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq":
    mode: "000755"
    content: |
    #!/bin/bash

    # . /opt/elasticbeanstalk/containerfiles/envvars
    . /opt/elasticbeanstalk/support/envvars

    PIDFILE=$EB_CONFIG_APP_PIDS/sidekiq.pid

    cd $EB_CONFIG_APP_CURRENT

    if [ -f $PIDFILE ]
    then
    SIDEKIQ_LIVES=$(/bin/ps -o pid= -p `cat $PIDFILE`)
    if [ -z $SIDEKIQ_LIVES ]
    then
    rm -rf $PIDFILE
    else
    kill -TERM `cat $PIDFILE`
    sleep 10
    rm -rf $PIDFILE
    fi
    fi

    BUNDLE=/usr/local/bin/bundle
    SIDEKIQ=/usr/local/bin/sidekiq

    # $BUNDLE exec $SIDEKIQ \
    # -e production \
    # -P /var/app/containerfiles/pids/sidekiq.pid \
    # -C /var/app/current/config/sidekiq.yml \
    # -L /var/app/containerfiles/logs/sidekiq.log \
    # -d

    RAILS_ENV=production bundle exec $SIDEKIQ \
    -e production \
    -P /var/app/support/pids/sidekiq.pid \
    -C /var/app/current/config/sidekiq.yml \
    -L log/sidekiq.log \
    -d

    "/opt/elasticbeanstalk/hooks/appdeploy/pre/03_mute_sidekiq":
    mode: "000755"
    content: |
    #!/bin/bash

    # . /opt/elasticbeanstalk/containerfiles/envvars
    . /opt/elasticbeanstalk/support/envvars

    PIDFILE=$EB_CONFIG_APP_PIDS/sidekiq.pid

    if [ -f $PIDFILE ]
    then
    SIDEKIQ_LIVES=$(/bin/ps -o pid= -p `cat $PIDFILE`)
    if [ -z $SIDEKIQ_LIVES ]
    then
    rm -rf $PIDFILE
    else
    kill -USR1 `cat $PIDFILE`
    sleep 10
    fi
    fi
    4 changes: 4 additions & 0 deletions db_seed.config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    container_commands:
    seeddb:
    command: 'export HOME=/root; rake db:seed'
    leader_only: true
    3 changes: 3 additions & 0 deletions nokogiri_command.config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    commands:
    test:
    command: "bundle config build.nokogiri --use-system-libraries"
    9 changes: 9 additions & 0 deletions packages.config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # .ebextensions/packages.config
    packages:
    yum:
    postgresql-devel: []
    git: []
    libxml2: []
    libxml2-devel: []
    libxslt: []
    libxslt-devel: []