Could anyone please clarify instructions presented in here? I will share the experience in part A below which hopefully will motivate anybody to find couple minutes to rewrite it in a more accessible language. Many people will be grateful and more enthusiastic as when you spend over an hour to deploy something you start to get upset and deeply respect your devops colleagues doing your errands at work in 5 minutes(max) .
Part B is a specific problem running application with init.d again related to lack of documentation.
Part A:
My aim is to prepare my own linux machine and CI enviornment with some basic linux knowledge. So I want to start spring boot as a service instead of generating .war and deploying to tomcat.
Until I followed the steps to the end and ran spring boot app as a service I wasn't even sure if the script going to be embedded by spring-boot-maven-executable-script-in-maven-declaration-magic or I need to provide this script myself - the language used there is odd.
If you start reading from:
"The default executable script that can be embedded into Spring Boot jars will act as an init.d script when it is symlinked to /etc/init.d ". Then you have questions in your head if it "can be embedded" is that this extra maven configuration which makes it possible or this extra maven configuration makes it possible as well as creating the script for you?
Thinking. "Ok..." - So I ran it, I received one line with "process started under PID" ("ok, no reassuring logs to tell that it is what I just ran, but something happened right?")
Since the application did not start successfully(127.0.0.1:8080 dead) I could not know if it ever started. So I kept re-reading until found /var/app.log file (as my app name , symlink and jar is named 'app'). Reassured that I ran my app, I realized that the "default profile" was triggered instead of 'dev', which in my case not going to preconfigure data source so my next objective is to change profile ->
Part B: I How to run my application under certain profile with this script? As there is no enough information in the documentation I am not even sure what to do.
Citing:
"55.1.3 Customizing the startup script
The script accepts the following parameters as environment variables, so you can change the default behavior in a script or on the command line:"
So I need to change some script which is somehow magically created for me in some magical location. Which is still not confirmed in my head until somebody kindly clarifies.
So how can I change the script which somehow works for my .jar and I don't know about it's existence? How can modify "sudo service app start" to start like:
java -jar -Dspring.profiles.active=dev application-1.0-SNAPSHOT.jar
I remember a fairy tale where good task was arranged by a king for some adventurer:
"Go there - don't know where, find something - don't know what". I feel similar now. I admit all of this is just 'eez' basic linux ops, java stuff but thrown out of the context by this very useful feature but under-documented I am in struggle and need help.
Mkyong documentation on setting up tomcat8 as a service took me 5 min.. just for comparison.
A lot of the documentation was written immediately after the feature was added, and probably makes too many assumptions. We'll try to improve it.
For you specific case, you probably don't need to directly customize the embedded script. We provide that as an option in case you want to take complete control, but the default one supports configuration options that will probably work for you.
What you probably want to do is create a app.conf file that sits next to your jar. The name of this file needs to exactly match the name of the jar (i.e. if your app is called customer-app-1.0.jar you need customer-app-1.0.conf in the same directory). Inside the .conf file you can use the customize options mentioned in the documentation. In your case you probably want:
JAVA_OPTS="-Dspring.profiles.active=dev"
Thank you Phill, works like clock.
Hi,
Any ideas why the stdout log has root group permissions?
-rw-r--r-- 1 gxdev gxdv 8907706 Sep 22 13:09 web.logback.log
-rw-r----- 1 gxdev root 69304 Sep 22 13:09 web.stdout.log
..changing the group on the symlink doesn't make a difference.
Thanks
Antony
@waazkd if you think you've found a new bug please raise another issue with the steps required to replicate it.
@philwebb What should be the conf file name if I use symlinks? Say for example my application is installed under /opt/myapplication/ and I have version number in my jar filename myapp-0.0.1.jar. The directory structure looks like below:
-r-------- 1 root root 41 Feb 3 17:20 myapp.conf
drwxr-xr-x 2 root root 4096 Feb 3 17:38 logs
-rwxr-xr-x 1 root root 55599628 Jun 2 17:04 myapp-0.0.1.jar
lrwxrwxrwx 1 root root 25 Jun 2 17:05 myapp.jar -> myapp-0.0.1.jar
Here is how the init.d script is installed:
lrwxrwxrwx 1 root root 40 Jun 2 16:17 myapp -> /opt/myapplication/myapp.jar
With this setting, spring.profiles.active set in the conf file is not being picked up. What is the right way of setting the active profile?
Note: I'm using Spring Boot v1.4.2.RELEASE
@prasenjithaty Please use stackoverflow.com for questions or join us on gitter.im. We prefer to keep the issue tracker for bugs and enhancement requests.
Most helpful comment
A lot of the documentation was written immediately after the feature was added, and probably makes too many assumptions. We'll try to improve it.
For you specific case, you probably don't need to directly customize the embedded script. We provide that as an option in case you want to take complete control, but the default one supports configuration options that will probably work for you.
What you probably want to do is create a
app.conffile that sits next to your jar. The name of this file needs to exactly match the name of the jar (i.e. if your app is calledcustomer-app-1.0.jaryou needcustomer-app-1.0.confin the same directory). Inside the.conffile you can use the customize options mentioned in the documentation. In your case you probably want: