Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a Procfile have comments?

Is it possible to put comments in a Procfile? If so, what is the syntax?

Not sure if this matters, but I am hosting on Heroku.

like image 509
Aaron Gray Avatar asked May 06 '16 20:05

Aaron Gray


People also ask

What should be in Procfile?

Procfile format<process type> is an alphanumeric name for your command, such as web , worker , urgentworker , clock , and so on. <command> indicates the command that every dyno of the process type should execute on startup, such as rake jobs:work .

What does a Procfile do?

A Procfile is a mechanism for declaring what commands are run by your application's containers on the Deis platform. It follows the process model. You can use a Procfile to declare various process types, such as multiple types of workers, a singleton process like a clock, or a consumer of the Twitter streaming API.

Is Procfile case sensitive?

Procfile Naming and Location py . Note that naming the file procfile will not work either, as it is case sensitive.

What is Procfile in Ruby on Rails?

At it simplest, the Procfile is where you declare the one or more processes to be run for your app to function. Heroku's docs do a great job of explaining the Procfile format, so this post will focus on a bit more advanced usage.


2 Answers

Yes, you can put comments in a Procfile. I know of two programs which parse Procfiles, foreman and forego.

In foreman, which originated the Procfile format, a Procfile can contain comments, blank lines, and in fact any line that doesn't look like a meaningful Procfile line.

From the class that parses a Procfile:

# A valid Procfile entry is captured by this regex: # #   /^([A-Za-z0-9_]+):\s*(.+)$/ # # All other lines are ignored. 

forego, which Heroku uses, follows the same scheme.

like image 78
Dave Schweisguth Avatar answered Oct 05 '22 15:10

Dave Schweisguth


As a 2020 update to this question, Heroku has switched from using Forego within Heroku Local to node-foreman (a port of the original foreman). That being said, not much has changed regarding how Procfiles are read and wrote by foreman since 2017. However around the end of June 2016 (after the May 2016 update to this question), it seems users have found processes will still be launched from lines starting with #. The following will still launch a process:

# foo: cd foo && bundle exec rails s -p 3000 

On the other hand, it seems // does prevent a process from being launched on that line. Preventing the following from running:

// foo: cd foo && bundle exec rails s -p 3000 

You may be able to use either one to create comments since, as the above suggests, lines starting with # will be not be read unless they have a valid process declared on it. On the other hand, if you're attempting to comment out a line with a valid process declared on it, it seems // is the comment style to use.

like image 41
Nick C Avatar answered Oct 05 '22 16:10

Nick C