Created
December 13, 2019 16:14
-
-
Save ctrlaltdylan/f75b2e38bbbf725acb6d48283fc2f174 to your computer and use it in GitHub Desktop.
EBextension for starting Sidekiq Process on Elasticbeanstalk
This file contains hidden or 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: | |
"/opt/elasticbeanstalk/support/conf/sidekiq.conf": | |
mode: "000755" | |
content: | | |
description "Elastic Beanstalk Sidekiq Upstart Manager" | |
start on runlevel [2345] | |
stop on runlevel [06] | |
# explained above | |
respawn | |
respawn limit 3 30 | |
script | |
# scripts run in /bin/sh by default | |
# respawn as bash so we can source in rbenv | |
exec /bin/bash <<"EOT" | |
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 | |
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) | |
cd $EB_APP_DEPLOY_DIR | |
su -s /bin/bash -c "bundle exec sidekiq -e production -L ${EB_APP_DEPLOY_DIR}/log/sidekiq.log -C ${EB_APP_DEPLOY_DIR}/config/sidekiq.yml -P ${EB_APP_PID_DIR}/sidekiq.pid" | |
EOT | |
end script | |
view raw | |
0001_sidekiq_upstart.config hosted with ❤ by GitHub |
This file contains hidden or 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: | |
"/opt/elasticbeanstalk/hooks/appdeploy/pre/03_mute_sidekiq.sh": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
. /opt/elasticbeanstalk/support/envvars | |
PIDFILE=/var/app/containerfiles/pids/sidekiq.pid | |
if [ -f ${PIDFILE} ] | |
then | |
kill -USR1 `cat ${PIDFILE}` | |
rm -rf /var/app/containerfiles/pids/sidekiq.pid | |
fi | |
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq.sh": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
initctl restart sidekiq || initctl start sidekiq | |
"/opt/elasticbeanstalk/hooks/configdeploy/pre/03_mute_sidekiq.sh": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
. /opt/elasticbeanstalk/support/envvars | |
PIDFILE=/var/app/containerfiles/pids/sidekiq.pid | |
if [ -f ${PIDFILE} ] | |
then | |
kill -USR1 `cat ${PIDFILE}` | |
rm -rf /var/app/containerfiles/pids/sidekiq.pid | |
fi | |
"/opt/elasticbeanstalk/hooks/configdeploy/post/50_restart_sidekiq.sh": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
initctl restart sidekiq || initctl start sidekiq | |
"/opt/elasticbeanstalk/hooks/restartappserver/pre/03_mute_sidekiq.sh": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
. /opt/elasticbeanstalk/support/envvars | |
PIDFILE=/var/app/containerfiles/pids/sidekiq.pid | |
if [ -f ${PIDFILE} ] | |
then | |
kill -USR1 `cat ${PIDFILE}` | |
rm -rf /var/app/containerfiles/pids/sidekiq.pid | |
fi | |
"/opt/elasticbeanstalk/hooks/restartappserver/post/50_restart_sidekiq.sh": | |
mode: "000755" | |
content: | | |
#!/bin/bash | |
initctl restart sidekiq || initctl start sidekiq |
This file contains hidden or 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/init/sidekiq.conf": | |
mode: "120400" | |
content: "/opt/elasticbeanstalk/support/conf/sidekiq.conf" | |
commands: | |
reload_initctl_for_sidekiq: | |
command: "initctl reload-configuration" |
why you first write /opt/elasticbeanstalk/support/conf/sidekiq.conf
with exec flags, then make a copy in /etc/init without ?
do you really need both?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
please clean your first file! i think end of file has extra lines.