# Launching Multiple Processes with a Single Command in Rails

*Published on January 30, 2022*

---


An application doesn’t exist in isolation. Usually, it depends on other processes to work correctly, such as a database, JavaScript / CSS compilers, Redis, etc.

So far, whenever I started the Rails app, I launched these supporting processes in multiple terminal windows. This week, I learned a new way to do this using a single command using the&nbsp;[Foreman](https://github.com/ddollar/foreman)&nbsp;gem, which has saved me a lot of time.

Here’s a simple way to achieve this, inspired by the&nbsp;[tailwindcss-rails](https://github.com/rails/tailwindcss-rails)&nbsp;gem.

**Step 1: Create an executable dev file in the bin/ directory**

```bash
cd bin
touch dev
chmod 755 bin/dev
```

**Step 2: Add Foreman script to your bin/dev file**

```bash
#!/usr/bin/env bash

if ! command -v foreman &> /dev/null
then
  echo "Installing foreman..."
  gem install foreman
fi

foreman start -f Procfile.dev
```

**Step 3: Add the procfile**

```text
web: bin/rails server -p 3000
css: bin/rails tailwindcss:watch
js: ..
mysql: ..
redis: ..
```

Now all you have to do is run the&nbsp;`bin/dev`&nbsp;command from the root of your rails application, and Foreman takes care of starting the processes listed in the Procfile.

I hope that helps.

