Skip to content

Commit a488314

Browse files
committed
docs: document the Procfile format
Since this isn't well-specified online, explicitly state what is a valid Procfile so that users aren't confused as to why their files do not validate.
1 parent 5c3e32a commit a488314

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,41 @@ Install it using the "go get" command:
88

99
go get github.com/josegonzalez/go-procfile-util
1010

11+
## What is a Procfile
12+
13+
A Procfile is a file that was [promoted by Heroku](https://blog.heroku.com/the_new_heroku_1_process_model_procfile) for their platform as an easy way to specify one or more distinct processes to run within Heroku. This format has since been picked up by various other tools and platforms.
14+
15+
The `procfile-util` tool expects a Procfile to be defined as one or more lines containing one of:
16+
17+
- a comment (preceeded by a `#` symbol)
18+
- a process-type/command combination (with optional trailing whitespace or trailing comment)
19+
- when there is a trailing comment, the `#` symbol _must_ be preceeded by one or more `whitespace` characters.
20+
- a blank line (with optional trailing whitespace)
21+
22+
Comments and blank lines are ignored, while process-type/command combinations look like the following:
23+
24+
```
25+
<process type>: <command>
26+
```
27+
28+
The syntax is defined as follows:
29+
30+
- `<process type>` – a valid DNS Label Name as per [RFC 1123](https://tools.ietf.org/html/rfc1123), a process type is a name for your command, such as `web`, `worker`, `urgentworker`, `clock`, etc.
31+
- `<command>` – a command used to launch the process, such as `rake jobs:work`
32+
33+
This syntax differs common interpretations of validd `<process type>` values in that we define the process type as a DNS Label name, versus the regex `[A-Za-z0-9_]+`. The reason for this is that processes defined within Procfiles are commonly used in DNS entries. Rather than have a second level of platform-specific validation in place, this project implicitly defines the format for the process-type.
34+
35+
Given the above, a valid process type can be generalized to the following rules (as taken from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names)):
36+
37+
- contain at most 63 characters
38+
- contain only lowercase alphanumeric characters or '-'
39+
- start with an alphanumeric character
40+
- end with an alphanumeric character
41+
42+
Additionally, should a Procfile contain a line that does not match one of the three patterns mentioned above, the entire Procfile is considered invalid, and will not be processed. This is to avoid issues where a Procfile may contain merge conflicts or other improper content, thus resulting in unwanted runtime behavior for applications.
43+
44+
Finally, process types within a Procfile may not overlap and must be unique. Rather than assuming that the last or first specified is correct, `procfile-util` will fail to parse the Procfile with the relevant error.
45+
1146
## Usage
1247

1348
All commands take a `-P` or `--procfile` flag to specify an alternative `Procfile` path. If not specified, `procfile-util` will attempt to read the `Procfile` from the current directory.

0 commit comments

Comments
 (0)