Pushing an App with Multiple Processes (Beta)

Page last updated:

This topic describes how to push and manage apps with multiple processes.

Note: This is a beta feature. Because the CLI may change, this feature is not recommended for use in scripts until it is generally available.

Note: This topic includes references to cf CLI v7 beta commands. Consider the following when using these commands:
  • cf CLI v7 beta and CAPI v3 are both in active development and subject to change.
  • cf CLI v7 beta is developed and tested against the latest CAPI release candidate.
  • cf CLI v7 beta does not yet use CAPI v3 for all commands. Some commands still use CAPI v2 during beta.
For more information, see Upgrading to cf CLI v7 (Beta).

About Processes

The CAPI v3 API supports using a single command to push apps that run multiple processes, such as a web app that has a UI process and a worker process. To push an app that creates multiple processes from the same codebase, you first define its processes in a Procfile. See Push an App with Multiple Processes.

For more information about processes, see the Processes section of the CAPI v3 documentation.

Push an App with Multiple Processes

You can push an app with multiple processes using a Procfile. Follow the procedure below.

Note: You can also push an app with multiple processes using an app manifest. See The app manifest specification in the CAPI v3 docs.

  1. Create a file named Procfile in the root of your app directory.

    Note For more information about Procfiles, see the Procfiles section of the CAPI v3 documentation.

  2. Add each process and its start command to the Procfile. See the following example:

    web: bundle exec rackup config.ru -p $PORT
    worker: bundle exec rake worker:start
    
  3. Push the app:

    • cf CLI v7:

      cf7 push myapp
      
    • cf CLI v6:

      cf v3-push myapp
      

By default, the web process has a route and one instance. Other processes have zero instances by default.

Scale a Process

To scale an app process, run the following command:

  • cf CLI v7:

    cf7 scale APP-NAME --process PROCESS-NAME -i INSTANCE-COUNT
    
  • cf CLI v6:

    cf v3-scale APP-NAME --process PROCESS-NAME -i INSTANCE-COUNT
    

View Processes

To view the processes running as part of an app, run cf APP-NAME. See the following example in which the app has a web and a worker process.

Note: In cf CLI v7, the v3-prefix is not required.

$ cf app myapp
 Showing health and status for app myapp in org test / space test as admin...

name: myapp
 requested state: started
 processes: web:1/1, worker:2/2
 memory usage: 256M x 1, 256M x 2
 routes: myapp.cloudfoundry.example.com
 stack: cflinuxfs3
 buildpacks: ruby

web:1/1
 state since cpu memory disk
 #0 running 2017-09-25 15:43:26 PM 0.2% 18.9M of 256M 84.4M of 1G

worker:2/2
 state since cpu memory disk
 #0 running 2017-09-25 15:49:46 PM 0.1% 5M of 256M 73M of 1G
 #1 running 2017-09-25 15:49:46 PM 0.1% 5M of 256M 73M of 1G