2

I have followed instructions from spring-boot documentation and successfully deployed spring-boot as service in centos.

All the following commands work

sudo /etc/init.d/myapp start
sudo /etc/init.d/myapp stop
sudo /etc/init.d/myapp status

application.properties has database credentials that I need to override during deployment. I want to set it as RUN_ARGS environment variable simply because my CI server (Jenkins) will be deploying the app, setting up environment variable and start the service

so I was hoping the following that the following two commands will work in my centos machine

export RUN_ARGS='spring.datasource.username=XXXXX,spring.datasource.password=YYYY'
sudo /etc/init.d/myapp start

However, these two values are not picked up spring boot app. It rather takes default values in application.properties and the service fails when initializing the pool.

what is wrong with the way I am passing the RUN_ARGS. what is the correct way to do it?

I also tried using JAVA_OPTS but of no use.

export JAVA_OPTS='-Dspring.datasource.username=XXXXX,-Dspring.datasource.password=YYYY'
sudo /etc/init.d/myapp start
brain storm
  • 30,124
  • 69
  • 225
  • 393

1 Answers1

2

If I remember correctly it should be

 sudo /etc/init.d/myapp start --spring.datasource.username=xxx --spring.datasource.password=yyy
ndrone
  • 3,524
  • 2
  • 23
  • 37
  • passing multiple commands did not work. only the first one seems to get picked up. Is there a delimiter I need to use. `--spring.datasource.username=xxx --spring.datasource.password=yyy`. of these only, username is rightly set – brain storm Oct 17 '16 at 19:39
  • you probably need to wrap all the args in double quotes. – ndrone Oct 17 '16 at 21:00
  • I tried `"--spring.datasource.username=xxx --spring.datasource.password=yyy"`. That did not work either – brain storm Oct 17 '16 at 21:52
  • I posted that as another question here.http://stackoverflow.com/questions/40095464/multiple-parameters-not-getting-passed-when-i-start-my-spring-boot-application-i – brain storm Oct 17 '16 at 21:53