-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
171 additions
and
7 deletions.
There are no files selected for viewing
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Sidekiq interaction and startup script | ||
commands: | ||
create_post_dir: | ||
command: "mkdir -p /opt/elasticbeanstalk/hooks/appdeploy/post" | ||
ignoreErrors: true | ||
files: | ||
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq.sh": | ||
mode: "000755" | ||
owner: root | ||
group: root | ||
content: | | ||
#!/usr/bin/env bash | ||
. /opt/elasticbeanstalk/support/envvars | ||
|
||
EB_APP_DEPLOY_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir) | ||
EB_APP_PID_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir) | ||
EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user) | ||
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir) | ||
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir) | ||
|
||
. $EB_SUPPORT_DIR/envvars | ||
. $EB_SCRIPT_DIR/use-app-ruby.sh | ||
|
||
SIDEKIQ_PID=$EB_APP_PID_DIR/sidekiq.pid | ||
SIDEKIQ_CONFIG=$EB_APP_DEPLOY_DIR/config/sidekiq.yml | ||
SIDEKIQ_LOG=$EB_APP_DEPLOY_DIR/log/sidekiq.log | ||
|
||
cd $EB_APP_DEPLOY_DIR | ||
|
||
if [ -f $SIDEKIQ_PID ] | ||
then | ||
su -s /bin/bash -c "kill -TERM `cat $SIDEKIQ_PID`" $EB_APP_USER | ||
su -s /bin/bash -c "rm -rf $SIDEKIQ_PID" $EB_APP_USER | ||
fi | ||
|
||
. /opt/elasticbeanstalk/support/envvars.d/sysenv | ||
|
||
sleep 10 | ||
|
||
su -s /bin/bash -c "bundle exec sidekiq \ | ||
-e $RACK_ENV \ | ||
-P $SIDEKIQ_PID \ | ||
-C $SIDEKIQ_CONFIG \ | ||
-L $SIDEKIQ_LOG \ | ||
-d" $EB_APP_USER | ||
|
||
"/opt/elasticbeanstalk/hooks/appdeploy/pre/03_mute_sidekiq.sh": | ||
mode: "000755" | ||
owner: root | ||
group: root | ||
content: | | ||
#!/usr/bin/env bash | ||
. /opt/elasticbeanstalk/support/envvars | ||
|
||
EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user) | ||
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir) | ||
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir) | ||
|
||
. $EB_SUPPORT_DIR/envvars | ||
. $EB_SCRIPT_DIR/use-app-ruby.sh | ||
|
||
SIDEKIQ_PID=$EB_APP_PID_DIR/sidekiq.pid | ||
if [ -f $SIDEKIQ_PID ] | ||
then | ||
su -s /bin/bash -c "kill -USR1 `cat $SIDEKIQ_PID`" $EB_APP_USER | ||
fi |
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Set permissions for files accessed by Sidekiq | ||
files: | ||
"/opt/elasticbeanstalk/hooks/appdeploy/post/51_chmod_logs.sh": | ||
mode: "000755" | ||
owner: root | ||
group: root | ||
content: | | ||
#!/usr/bin/env bash | ||
. /opt/elasticbeanstalk/support/envvars | ||
|
||
EB_APP_DEPLOY_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir) | ||
APP_LOG_DIR=$EB_APP_DEPLOY_DIR/log | ||
|
||
SIDEKIQ_LOG=$APP_LOG_DIR/sidekiq.log | ||
|
||
case $RACK_ENV in | ||
"integration") | ||
RAILS_LOG=$APP_LOG_DIR/integration.log | ||
;; | ||
"staging") | ||
RAILS_LOG=$APP_LOG_DIR/staging.log | ||
;; | ||
"production") | ||
RAILS_LOG=$APP_LOG_DIR/production.log | ||
;; | ||
esac | ||
|
||
touch $SIDEKIQ_LOG | ||
chmod 0664 $SIDEKIQ_LOG | ||
touch $RAILS_LOG | ||
chmod 0664 $RAILS_LOG |
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
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
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
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
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
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
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
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
config = YAML.load(ERB.new(IO.read(Rails.root + 'config' + 'redis.yml')).result)[Rails.env].with_indifferent_access | ||
|
||
redis_conn = { url: "redis://#{config[:host]}:#{config[:port]}/" } | ||
|
||
Sidekiq.configure_server do |s| | ||
s.redis = redis_conn | ||
end | ||
|
||
Sidekiq.configure_client do |s| | ||
s.redis = redis_conn | ||
end |
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
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
default: | ||
host: <%= ENV['REDIS_HOST'] || "localhost" %> | ||
port: 6379 | ||
db: 0 | ||
development: | ||
host: <%= ENV['REDIS_HOST'] || "localhost" %> | ||
port: 6379 | ||
db: 1 | ||
test: | ||
host: <%= ENV['REDIS_HOST'] || "localhost" %> | ||
port: 6379 | ||
db: 2 | ||
integration: | ||
host: <%= ENV['REDIS_HOST'] || "localhost" %> | ||
port: 6379 | ||
db: 3 | ||
staging: | ||
host: <%= ENV['REDIS_HOST'] || "localhost" %> | ||
port: 6379 | ||
db: 4 | ||
production: | ||
host: <%= ENV['REDIS_HOST'] || "localhost" %> | ||
port: 6379 | ||
db: 5 |
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
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 file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
:queues: | ||
- default |