A common setup I have for the applications that I build is:
Rails application Sidekiq for managing background jobs Redis for working with SidekiqIn order to get a program with this structure running locally I need to run the following commands everytime that I start the program:
run redis-server to startup the Redis database run bundle exec sidekiq to startup the sidekiq queue manager run rails s to startup the local development serverThis process can become tiresome when performed multiple times a day. That's where the Foreman gem comes into play. Start by adding the 'foreman' gem to your Gemfile in the development block.
After running bundle install, you can create a Procfile.dev file located at the root of your project. In the file you can place the processes that you want to run:
With all of this in place you can run the command:
foreman start -f Procfile.dev
And foreman will startup Redis, Sidekiq and the Rails server for you!
Now if you're using the same setup on an app engine such as Heroku, you will also need a Procfile to manage your processes, so you can create another file at the root of your project called Procfile (app engines like Heroku are smart enough to pick out the Procfile and they'll ignore the Procfile.dev file).
Inside of the new Procfile you can place code such as:
You're now setup with an automated process workflow that will run for both development and production environments.