Search code examples
rubybundlerforeman

How can I run multiple apps of multiple bundle with foreman


I have a ruby app that depends of several web-services i've built.

To start all together I've got the following Procfile:

mondodb: /home/dwaynemac/mongodb/bin/mongod 
accounts: ./script/start_accounts.sh
contacts: ./script/start_contacts.sh
activity: ./script/start_activity_stream.sh
web: ./script/start.sh

Each of this start_xxx.sh script do something like:

cd ../activity_stream; bundle exec unicorn -p 3003 -c ./config/unicorn.rb

If I manually run these previous line activity_stream runs ok. But when ran from foreman some gems are not recognized. As if the bundle was not correctly built.

Example error:

activity_stream/config/boot.rb:2:in `require': no such file to load -- grape (LoadError)

Solution

  • Use the subcontractor gem to change working directory:

    image_fallback: subcontract -d lib/rack/img_fallback/ -- bundle exec unicorn -c unicorn.conf config.ru