Created
June 20, 2024 14:25
-
-
Save slhck/e0a9dfb971fc08301ae1cf054c92346c to your computer and use it in GitHub Desktop.
A Docker entrypoint for starting Foreman with multiple Sidekiq processes
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
#!/usr/bin/env bash | |
# | |
# A Docker entrypoint for starting Foreman with multiple Sidekiq processes | |
# | |
# Required in the Dockerfile: | |
# | |
# gem install foreman --no-document | |
echo_stderr() { | |
echo "$@" 1>&2 | |
} | |
on_exit() { | |
echo_stderr "exiting" | |
} | |
trap on_exit EXIT | |
SIDEKIQ_WORKERS=${SIDEKIQ_WORKERS:-1} | |
echo_stderr "Starting $SIDEKIQ_WORKERS Sidekiq worker(s)" | |
procfile_template=$(cat <<EOF | |
worker: bundle exec sidekiq -C config/sidekiq.yml -e ${RAILS_ENV:-development} | |
EOF | |
) | |
echo "$procfile_template" > Procfile | |
exec foreman start -f Procfile --formation worker=$SIDEKIQ_WORKERS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment