This Heroku Help page suggests I can run multiple commands backgrounded, followed by wait -n, in my Procfile. Their example:
web: puma -C config/puma.rb & sidekiq & wait -n
In my example, the commands I want to run are in different directories, so I wrote:
web: cd api/ && bundle exec puma -C config/puma.rb & cd .. && sh target/bin/worker & wait -n
Problem
My heroku app crashes. heroku logs shows:
2020-04-26T22:50:37.104343+00:00 app[web.1]: sh: 0: Can't open target/bin/worker
2020-04-26T22:50:55.157670+00:00 heroku[web.1]: State changed from starting to crashed
But if I do heroku run bash and then sh target/bin/worker, it runs fine. And all the files are where I expect:
$ heroku run bash
Running bash on [redacted]... up, run.[redacted] (Free)
~ $ ls -al api/config/puma.rb
-rw------- 1 u37764 dyno 1579 Apr 26 22:43 api/config/puma.rb
~ $ ls -al target/bin/worker
-rw------- 1 u37764 dyno 11952 Apr 26 22:45 target/bin/worker
So I think something may be incorrect with the way I'm chaining commands (e.g. mixing && and &). I saw this related bash question but still couldn't figure out the correct syntax.
What is it?
I also tried…
pumaneeds to be run from inside theapi/directory, so e.g.web: puma -C api/config/puma.rb & sh target/bin/worker & wait -ndoesn't work either.)web: sh start.shwherestart.shcontains:#!/usr/bin/env sh cd api/ bundle exec puma -C config/puma.rb & cd .. sh target/bin/worker & wait -n