-
-
Save anonymous/2cb1e0961657502e1cdded814ce5a77a to your computer and use it in GitHub Desktop.
Rails Redis Config
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
commands: | |
000_dd: | |
command: echo “noswap”#dd if=/dev/zero of=/swapfile bs=1M count=3072 | |
001_mkswap: | |
command: echo “noswap”#mkswap /swapfile | |
002_swapon: | |
command: echo “noswap”#swapon /swapfile |
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
# 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
files: | |
"/etc/nginx/conf.d/webapp_healthd.conf" : | |
mode: "000755" | |
owner: root | |
group: root | |
content: | | |
upstream my_app { | |
server unix:///var/run/puma/my_app.sock; | |
} | |
log_format healthd '$msec"$uri"' | |
'$status"$request_time"$upstream_response_time"' | |
'$http_x_forwarded_for'; | |
server { | |
listen 80; | |
server_name _ localhost; # need to listen to localhost for worker tier | |
root /var/app/current/public; | |
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") { | |
set $year $1; | |
set $month $2; | |
set $day $3; | |
set $hour $4; | |
} | |
access_log /var/log/nginx/access.log main; | |
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd; | |
try_files $uri/index.html $uri @my_app; | |
location @my_app { | |
proxy_pass http://my_app; # match the name of upstream directive which is defined above | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
location /assets { | |
alias /var/app/current/public/assets; | |
gzip_static on; | |
gzip on; | |
expires max; | |
add_header Cache-Control public; | |
} | |
} | |
"/opt/elasticbeanstalk/hooks/appdeploy/post/03_restart_nginx.sh": | |
mode: "000755" | |
owner: root | |
group: root | |
content: | | |
#!/usr/bin/env bash | |
rm /etc/nginx/conf.d/webapp_healthd.conf.bak | |
rm /etc/nginx/conf.d/custom.conf | |
service nginx restart |
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
packages: | |
yum: | |
gcc-c++: [] | |
make: [] | |
git: [] | |
commands: | |
redis_script_01: | |
command: wget https://raw.github.com/KeithP/install-redis-amazon-linux-centos/master/redis-install-script.sh | |
redis_script_02: | |
command: chmod 777 redis-install-script.sh | |
redis_script_03: | |
command: ./redis-install-script.sh | |
redis_server_start: | |
command: service redis-server start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment