Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow SHOREMAN_CONCURRENCY to specify processes to be run (issue #7) #10

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ git clone https://github.com/statianzo/dokku-shoreman.git /var/lib/dokku/plugins
dokku plugins-install
```

## Usage

### Concurrency

Optionally, you can use the `SHOREMAN_CONCURRENCY` variable to control which
processes are started as well as how many. This is based on the
[foreman --concurrency][foreman] flag.

For e.g. SHOREMAN_CONCURRENCY=web=1,worker=2 will start one web process and two
worker processes. Any other process in the Procfile will be ignored.

All future deployments will use shoreman to start all processes.

## License
Expand Down Expand Up @@ -41,3 +52,4 @@ SOFTWARE.

[dokku]: https://github.com/progrium/dokku
[shoreman]: https://github.com/hecticjeff/shoreman
[foreman]: https://ddollar.github.io/foreman/
18 changes: 16 additions & 2 deletions post-release
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,25 @@ for file in \$HOME/.profile.d/*; do source \$file; done
hash -r
cd \$HOME

get_concurrency() {
name="\$1"
if [[ -z "\$SHOREMAN_CONCURRENCY" ]]; then
echo 1
else
echo $(echo "\$SHOREMAN_CONCURRENCY" | ruby -e "puts Hash[STDIN.read.split(',').map {|c|c.strip.split('=')}]['\$name'] || 0")
fi
}

while read line || [ -n "\$line" ]; do
name=\${line%%:*}
command=\${line#*: }
echo "Starting \${name}..."
sh -c "\${command} | sed -e 's/^/\${name}| /'" &
num_procs=\$(get_concurrency "\${name}")
if [[ \$num_procs -gt 0 ]]; then
echo "Starting \${name} (concurrency: \${num_procs})..."
for ((i=0;i<\$num_procs;i++)); do
sh -c "\${command} | sed -e 's/^/\${name}| /'" &
done
fi
done < "Procfile"

onexit() {
Expand Down