Pushing an App with Multiple Processes
Page last updated:
This topic describes how to push and manage apps with multiple processes.
About Processes
The Cloud Foundry API (CAPI) V3 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. For more information, see Push an App with Multiple Processes below.
For more information about processes, see Processes in the CAPI V3 documentation.
Push an App with Multiple Processes
To push an app with multiple processes using a Procfile:
Note: You can also push an app with multiple processes using an app manifest. For more information, see processes in App Manifest Attribute Reference.
Create a file named
Procfile
in the root of your app directory.Note: For more information about Procfiles, see Procfiles in the CAPI V3 documentation.
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
Push the app.
If you are using cf CLI v7, run:
cf push myapp
If you are using cf CLI v6, run:
cf v3-push myapp
Note: This command is experimental and unsupported. Consider upgrading to cf CLI v7 to use a supported version of this command. To upgrade to cf CLI v7, see Install cf CLI v7 in Upgrading to cf CLI v7.
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:
- cf CLI v7:
Run:
cf scale APP-NAME --process PROCESS-NAME -i INSTANCE-COUNT
Where:
APP-NAME
is the name of your app.PROCESS-NAME
is the name of the process you want to scale.INSTANCE-COUNT
is the number of instances to which you want to scale the process.
- cf CLI v6:
Run:
cf v3-scale APP-NAME --process PROCESS-NAME -i INSTANCE-COUNT
Where:
APP-NAME
is the name of your app.PROCESS-NAME
is the name of the process you want to scale.INSTANCE-COUNT
is the number of instances to which you want to scale the process.Note: This command is experimental and unsupported. Consider upgrading to cf CLI v7 to use a supported version of this command. To upgrade to cf CLI v7, see Install cf CLI v7 in Upgrading to cf CLI v7.
View Processes
To view the processes running as part of an app, run cf APP-NAME
, where APP-NAME
is the name of your app. See the following example in which the app has a web
and a worker
process.
$ 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