Foreman is a great tool for running multiple processes along side your rails project. Processes like Redis, SidekiqFaye or any other process that doesn’t run within Rails itself. Foreman runs in your development environment as well as your production environments. To use Foreman in production, you have to export it’s config file in one of the following formats:

Since most of the servers we work on are Ubuntu, and (newer versions of) Ubuntu come with Upstart preinstalled, we generate the Foreman export script to Upstart.

When recently deploying a customer’s project, we noticed that the Foreman Sidekiq process wasn’t starting up.

The Procfile we were working with had this content:

Exporting it generated these files:

Isolated the Sidekiq Upstart script and ran it by itself:

Resulted in:

Unfortunately there was no log output in the usual place: /var/log/upstart/myapp-staging-sidekiq-1.log
It would merely fail without a result.

After many hours of research, trial and error, the closest answer we came to was that bundle couldn’t be found (via PATH). Issue #443 states that you need to setup a .env file with your servers PATH because as of version 0.63 of Foreman it no longer assumes your PATH. However, most of our development happens on Macs so the environment variables are vastly different than the servers we deploy on. The solution that seems to work best for any server setup we deploy to is the following:

Notice that line 5 takes the current server’s path and assigns it to the .env file in the current directory. Line 6 and 7 setup the environment for the Foreman processes. This helps ensure the .env file is always running what the server is running as well as it gets updated when a new foreman:export command is executed.

Please let us know if you found this helpful.