How to write multi-line command in heroku procfile
Asked Answered
B

2

8

I have a long command line in heroku procfile and want to break it into multiple lines.

Using backslash like below didn't help...

Procfile:

web: java -Dserver.port=$PORT\ 
 -Djavax.net.ssl.keyStoreType=pkcs12\ 
 -Djavax.net.ssl.keyStore=$SOAP_SSL_KEYSTORE_PATH\ 
 -Djavax.net.ssl.keyStorePassword=$SOAP_SSL_KEYSTORE_PASSWORD\ 
 $JAVA_OPTS -jar pwr-mobile-rest-api-jar/target/pwr-mobile-rest-api-jar-runnable.jar

How can I format the procfile for better looking?

Borsch answered 1/6, 2020 at 16:23 Comment(0)
A
1

It works

echo \
hello world

It doesnt work

echo\
hello world

Put space before backslash and it should work.

Australasia answered 14/9, 2021 at 8:3 Comment(1)
This does not work for meMikamikado
E
0

I've spent quite a bit of time trying to get this working and come to the conclusion that it's not possible to do.

As per the Procfile-format docs

A Procfile declares its process types on individual lines

I tried wrapping the command in quotes (both single and double) and using sh -c "COMMAND" and wasn't able to get any option working.

As a result, I've concluded there is no way to do this directly in the Procfile.

The best alternative I can think of is to abstract the command(s) into a separate file, e.g. (run-web.sh) which looks like this:

my-command \
  --foo 1 \
  --bar 2

Then in the Procfile:

web: run-web.sh

Ensure that run-web.sh has execute permissions.

As a side note, there must be a space before \ when breaking a command only multiple lines.

Equatorial answered 19/4 at 11:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.