Skip to content

Instantly share code, notes, and snippets.

@steverob
Forked from t2/sidekiq.config
Last active September 24, 2015 19:24
Show Gist options
  • Save steverob/19daa36cc1ce53093edc to your computer and use it in GitHub Desktop.
Save steverob/19daa36cc1ce53093edc to your computer and use it in GitHub Desktop.

Revisions

  1. steverob renamed this gist Sep 24, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. steverob revised this gist Sep 24, 2015. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # Symlink the ondeck database.yml to database.yml.example
    # .ebextensions/database_yml.config
    files:
    "/opt/elasticbeanstalk/hooks/appdeploy/pre/01a_symlink_database_yml.sh":
    mode: "000777"
    content: |
    #!/bin/bash
    cd /var/app/ondeck/config
    ln -sf database.sample.yml database.yml
  3. steverob revised this gist Sep 24, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions sidekiq.config
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    # Original: http://www.snip2code.com/Snippet/256399/Amazon-Elastic-Beanstalk-Sidekiq
    # .ebextensions/sidekiq.config
    commands:
    create_post_dir:
    command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
  4. steverob revised this gist Sep 24, 2015. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions packages.config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # .ebextensions/packages.config
    packages:
    yum:
    git: []
    postgresql93-devel: []
  5. steverob revised this gist Sep 24, 2015. No changes.
  6. steverob revised this gist Sep 24, 2015. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions sidekiq.config
    Original file line number Diff line number Diff line change
    @@ -55,12 +55,11 @@ files:

    sleep 10

    bundle exec sidekiq \
    -e production \
    -P $EB_CONFIG_APP_PIDS/sidekiq.pid \
    -C $EB_CONFIG_APP_CURRENT/config/sidekiq.yml \
    -L $EB_CONFIG_APP_LOGS/sidekiq.log \
    -d
    su -s /bin/bash -c "bundle exec sidekiq \
    -P $EB_CONFIG_APP_PIDS/sidekiq.pid \
    -C $EB_CONFIG_APP_CURRENT/config/sidekiq.yml \
    -L $EB_CONFIG_APP_LOGS/sidekiq.log \
    -d" $EB_APP_USER

    "/opt/elasticbeanstalk/hooks/appdeploy/pre/03_mute_sidekiq":
    mode: "000755"
  7. @t2 t2 created this gist Feb 11, 2015.
    84 changes: 84 additions & 0 deletions sidekiq.config
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,84 @@
    # Original: http://www.snip2code.com/Snippet/256399/Amazon-Elastic-Beanstalk-Sidekiq
    commands:
    create_post_dir:
    command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
    ignoreErrors: true
    files:
    "/etc/rsyslog.d/11-sidekiq.conf":
    mode: '000644'
    content: |
    EB_CONFIG_APP_LOGS=$(/opt/elasticbeanstalk/bin/get-config container -k app_log_dir)

    $InputFileName $EB_CONFIG_APP_LOGS/sidekiq.log
    $InputFileTag sidekiq
    $InputFileStateFile sidekiq-state
    $InputFileSeverity info
    $InputFileFacility local6
    $InputRunFileMonitor

    "/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq":
    mode: "000755"
    content: |
    #!/bin/bash

    EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
    EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)
    EB_CONFIG_APP_CURRENT=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)
    EB_CONFIG_APP_LOGS=$(/opt/elasticbeanstalk/bin/get-config container -k app_log_dir)
    EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user)
    EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
    EB_CONFIG_APP_PIDS=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir)

    . $EB_SUPPORT_DIR/envvars
    . $EB_SCRIPT_DIR/use-app-ruby.sh

    cd $EB_CONFIG_APP_CURRENT

    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 20
    rm -rf $PIDFILE
    fi
    fi

    . $EB_SUPPORT_DIR/envvars.d/sysenv

    sleep 10

    bundle exec sidekiq \
    -e production \
    -P $EB_CONFIG_APP_PIDS/sidekiq.pid \
    -C $EB_CONFIG_APP_CURRENT/config/sidekiq.yml \
    -L $EB_CONFIG_APP_LOGS/sidekiq.log \
    -d

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

    EB_CONFIG_APP_PIDS=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir)

    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