Environment variables not available in Elastic Beanstalk Procfile

I am trying to configure a elastic beanstalk java application using environment variables via a Procfile, for example:

web: ./bin/myservice -Dhttp.port=$PORT

The environment variable is PORTset via AWS ui on the "Software Configuration" screen of my beanstalk environment.

However, the logs show that it is $PORTnot interpolated:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.whatever.services.myservice.Main.main(Main.scala)
Caused by: java.lang.NumberFormatException: For input string: "$PORT"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:569)

What is the correct way to pass parameters to my application?

Edit 1: This seems to be a problem with the sbt native packager plugin that I use to create the project distribution zip archive. The bin / myservice file that it creates interprets $ PORT literally and passes this application.

+2
1

-Dhttp.port=$PORT Procfile.

" " JAVA_OPTS -Dhttp.port=9000 ( 9000 , - nginx - 5000).

enter image description here

+1

Source: https://habr.com/ru/post/1666199/


All Articles