java – Starting Spring Boot as a foreground process from within a bash script

java – Starting Spring Boot as a foreground process from within a bash script

It looks like you are using the configuration(like port number etc… only for background and not used for foreground. You have not declared the variable (you missed this line)

`SPRING_OPTS=--spring.pid.file=${PID_FILE} ${SPRING_OPTS}` 

for foreground.

I tried to reproduce this problem with a new instance of Spring Boot. Wrote a quick bash script, and everything went fine!

Then, I started playing around with my original script, and found out that I was using SERVER_PORT variable (because I had an optional argument --port <num> for the user).

Apparently, this environment variable is also used by Spring Framework: https://www.concretepage.com/spring-boot/spring-boot-change-default-server-port#server_port

My mistake was exporting SERVER_PORT var (however, I needed it for other reasons).

Solution would be to either remove export from export SERVER_PORT= or rename variable to something else (which I ended up doing).

java – Starting Spring Boot as a foreground process from within a bash script

Leave a Reply

Your email address will not be published. Required fields are marked *