forked from cloudfoundry/docs-buildpacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prod-server.html.md.erb
85 lines (57 loc) · 3.69 KB
/
prod-server.html.md.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
title: Production Server Configuration
owner: Buildpacks
---
<strong><%= modified_date %></strong>
This topic describes how to configure a production server for your apps.
When you deploy an app, <%=vars.product_short%> determines the command used to start the app through the following process:
1. If the developer uses the command `cf push -c COMMAND`, then <%=vars.product_short%> uses `COMMAND` to start the app.
1. If the developer creates a file called a Procfile, <%=vars.product_short%> uses the Procfile to configure the command that launches the app.
See the <a href="#procfile">About Procfiles</a> section below for more information.
1. If the developer does not use `cf push -c COMMAND` and does not create a Procfile, then <%=vars.product_short%> does one of the following,
depending on the buildpack:
+ Uses a default start command.
+ Fails to start the app and shows a warning that the app is missing a Procfile.
##<a id="procfile"></a>About Procfiles
One reason to use a Procfile is specify a start command for buildpacks where a default start command is not provided.
Some buildpacks, such as Python, that work on a variety of frameworks, do not attempt to provide a default start command.
Another reason to use a Procfile is to configure a production server for web apps.
A Procfile enables you to declare required runtime processes, called process types, for your web app.
Process managers in a server use the process types to run and manage the workload.
In a Procfile, you declare one process type per line and use the following syntax:
<pre class="code">
PROCESS_TYPE: COMMAND
</pre>
* `PROCESS_TYPE` is `web`. A `web` process handles HTTP traffic.
* `COMMAND` is the command line to launch the process.
For example, a Procfile with the following content starts the launch script created by the build process for a Java app:
```
web: build/install/MY-PROJECT-NAME/bin/MY-PROJECT-NAME
```
##<a id="specify-server"></a>Specify a Web Server
Follow these steps to specify a web server using a Procfile.
For more information about configuring a web server for Rails apps, see the [Configure a Ruby Web Server](#config-ruby) section of this topic.
1. Create a blank file with a command line for a `web` process type.
2. Save it as a file named `Procfile` with no extension in the root directory of your app.
3. Push your app.
##<a id="config-ruby"></a>Configure a Ruby Web Server
<%=vars.product_short%> uses the default standard Ruby web server library WEBrick for Ruby and Ruby on Rails apps.
However, <%=vars.product_short%> can support a more robust production web server, such as Phusion Passenger, Puma, Thin, or Unicorn.
To instruct <%=vars.product_short%> to use a web server other than WEBrick, perform the following steps:
1. Add the gem for the web server to your Gemfile.
1. In the `config` directory of your app, create a new configuration file or modify an existing file.
Refer to your web server documentation for how to configure this file. The following example uses the Puma web server:
<pre class="code">
# config/puma.rb
threads 8,32
workers 3
on_worker_boot do
# things workers do
end
</pre>
1. In the root directory of your app, create a Procfile and add a command line for a `web` process type that points to your web server.
For information about configuring the specific command for a process type, see your web server documentation.<br/><br/>
The following example shows a command that starts a Puma web server and specifies the app runtime environment, TCP port, and paths to the server state information and configuration files:
<pre class="code">
web: bundle exec puma -e $RAILS_ENV -p 1234 -S ~/puma -C config/puma.rb
</pre>