-
-
Save ssaunier/44bbebb9c0fa01953860 to your computer and use it in GitHub Desktop.
# 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 |
It seems the new solution for Amazon Linux 2 is to use a
Procfile
to manage Sidekiq.https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ruby-platform-procfile.html https://github.com/mperham/sidekiq/wiki/Heroku
If you don't want to use a
Procfile
then I think the Sidekiq project also provided an example of how to perform the setup usingsystemd
https://github.com/mperham/sidekiq/blob/main/examples/systemd/sidekiq.service
Amazon Linux 2 and don't support the Procfile feature.
We can't use Procfile.
Did you use systemd
for sidekiq?
@ssaunier Thanks for update.
And I comment for someone who want to how to setup sidekiq on EB.
i found solution with predeploy
, postdeploy
sidekiq/sidekiq#4307 (comment)
https://www.barot.us/running-sidekiq-on-amazon-linux-2/
this gist was not working in elastic beanstalk for sidekiq.