Created
April 29, 2016 14:50
-
-
Save epintos/451e2115f0d89fb4b7820ec7efa276f5 to your computer and use it in GitHub Desktop.
AWS Elastic Beanstalk Sidekiq Config File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original: http://www.snip2code.com/Snippet/256399/Amazon-Elastic-Beanstalk-Sidekiq | |
commands: | |
create_pre_dir: | |
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/pre" | |
ignoreErrors: true | |
create_post_dir: | |
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post" | |
ignoreErrors: true | |
create_restartappserver_pre_dir: | |
command: "mkdir /opt/elasticbeanstalk/hooks/restartappserver/pre" | |
ignoreErrors: true | |
create_restartappserver_post_dir: | |
command: "mkdir /opt/elasticbeanstalk/hooks/restartappserver/post" | |
ignoreErrors: true | |
create_configdeploy_pre_dir: | |
command: "mkdir /opt/elasticbeanstalk/hooks/configdeploy/pre" | |
ignoreErrors: true | |
create_configdeploy_post_dir: | |
command: "mkdir /opt/elasticbeanstalk/hooks/configdeploy/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 | |
for i in `seq ${SIDEKIQ_PROCESSES:=1}` | |
do | |
PIDFILE=$EB_CONFIG_APP_PIDS/sidekiq-$i.pid | |
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 $PIDFILE \ | |
-C $EB_CONFIG_APP_CURRENT/config/sidekiq.yml \ | |
-L $EB_CONFIG_APP_LOGS/sidekiq.log \ | |
-d | |
done | |
"/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) | |
for i in `seq ${SIDEKIQ_PROCESSES:=1}` | |
do | |
PIDFILE=$EB_CONFIG_APP_PIDS/sidekiq-$i.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 | |
done | |
"/opt/elasticbeanstalk/hooks/restartappserver/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 | |
for i in `seq ${SIDEKIQ_PROCESSES:=1}` | |
do | |
PIDFILE=$EB_CONFIG_APP_PIDS/sidekiq-$i.pid | |
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 $PIDFILE \ | |
-C $EB_CONFIG_APP_CURRENT/config/sidekiq.yml \ | |
-L $EB_CONFIG_APP_LOGS/sidekiq.log \ | |
-d | |
done | |
"/opt/elasticbeanstalk/hooks/restartappserver/pre/03_mute_sidekiq": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
EB_CONFIG_APP_PIDS=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir) | |
for i in `seq ${SIDEKIQ_PROCESSES:=1}` | |
do | |
PIDFILE=$EB_CONFIG_APP_PIDS/sidekiq-$i.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 | |
done | |
"/opt/elasticbeanstalk/hooks/configdeploy/pre/03_mute_sidekiq": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
EB_CONFIG_APP_PIDS=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir) | |
for i in `seq ${SIDEKIQ_PROCESSES:=1}` | |
do | |
PIDFILE=$EB_CONFIG_APP_PIDS/sidekiq-$i.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 | |
done | |
"/opt/elasticbeanstalk/hooks/configdeploy/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 | |
for i in `seq ${SIDEKIQ_PROCESSES:=1}` | |
do | |
PIDFILE=$EB_CONFIG_APP_PIDS/sidekiq-$i.pid | |
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 $PIDFILE \ | |
-C $EB_CONFIG_APP_CURRENT/config/sidekiq.yml \ | |
-L $EB_CONFIG_APP_LOGS/sidekiq.log \ | |
-d | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment