Introduction
Foreman popularized the Procfile format for declaring the processes that make up an application. Originally created for Ruby apps, it became the standard way to describe process types and was adopted by Heroku and many other platforms as the default process declaration format.
What Foreman Does
- Reads a Procfile and starts all declared processes in parallel
- Streams color-coded log output from every process to one terminal
- Exports Procfile definitions to system init formats (systemd, upstart)
- Manages environment variables from a .env file
- Supports scaling individual process types with the
-cflag
Architecture Overview
Foreman parses the Procfile to build a list of process commands, then forks each one as a child process. It multiplexes their stdout and stderr streams into a single output with per-process color coding and name prefixes. On SIGTERM or SIGINT, it forwards the signal to all children and waits for graceful shutdown.
Self-Hosting & Configuration
- Install via RubyGems:
gem install foreman - Define processes in a
Procfileat the project root - Set environment variables in a
.envfile (not committed to Git) - Use
foreman start -f Procfile.devfor development-specific configs - Export to systemd with
foreman export systemd /etc/systemd/system
Key Features
- Single-command startup for multi-process applications
- Color-coded multiplexed log output for all processes
- Export to systemd, upstart, runit, and other init systems
- .env file support for environment variable management
- Process scaling with
-c web=2,worker=3syntax
Comparison with Similar Tools
- Overmind — Go-based Procfile manager with tmux integration; Foreman is Ruby-based and more widely known
- Hivemind — Minimal Go alternative; Foreman adds init system export and scaling
- docker-compose — Container-based orchestration; Foreman runs processes directly on the host
- honcho — Python port of Foreman; Foreman is the original with broader ecosystem support
FAQ
Q: Do I need Ruby installed to use Foreman? A: Yes, Foreman is distributed as a Ruby gem. Alternatives like Overmind or Hivemind are standalone binaries.
Q: Can I use Foreman in production?
A: Foreman is designed for development. For production, use foreman export to generate systemd or upstart service files.
Q: How does the .env file work? A: Foreman loads key-value pairs from .env into the environment of each process. Lines starting with # are treated as comments.
Q: Can I run only specific processes from a Procfile?
A: Yes. Use foreman start web to start only the web process, or foreman start -m web=1,worker=0 to select which types to run.