Skip to content

Instantly share code, notes, and snippets.

@slhck
Created June 20, 2024 14:25
Show Gist options
  • Save slhck/e0a9dfb971fc08301ae1cf054c92346c to your computer and use it in GitHub Desktop.
Save slhck/e0a9dfb971fc08301ae1cf054c92346c to your computer and use it in GitHub Desktop.
A Docker entrypoint for starting Foreman with multiple Sidekiq processes
#!/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