Gradle > How to stop a Spring Boot application launched with gradle bootRun? - spring-boot

I started a spring boot application using gradle bootRun.
Doing ctrl-c in the terminal where I launched the command does not stop the application.
What is then the correct way of stopping it?

You can use the command gradle -stop to stop the Spring Boot application.

Not sure what operating system you are using but I am on a mac and was having the same problem, command + C wasn't working (on a mac the command key is equal to the Windows control key) but I used control+C and it did work. If you're on a Windows machine this doesn't help you but thought this might help others who are new to a mac.

Related

Tomcat runs different application

I am developing a spring boot app with embeded tomcat server. When I start the project from spring and run it, I see the application which I ran on Virtual machine(windows)'s localhost while I should see my application which I am developing. It's strange that I see the application from virtual machine even when VM is shut down. Does it mean the tomcat has stored it in cache? How do I delete that data? I am using mac OS catalina.
Once run the below command in your terminal to kill your localhost then try
kill -9 $(lsof -t -i:8080)

How to run Spring Boot Application as a Service?

I have deployed my web application on company server by executing jar files then the project is running fine.But when i close the jar and again try to run the project on browser then client is not able to access the application.I want solution on this that if i close the jar then also client can access the application.
you can use this simple command to run a jar file as background service...
javaw -jar test.jar
after run this command you could not detect any change in cmd...and can close your command prompt. after 1 or 2 minute enter your URL in browser .. you will see your web program is running...
before run this command must be stop previously running jar for avoid same port conflict
for more details
When you close the cmd prompt, your java application will also be killed. To keep the java application running after closing the terminal you have to use the below command.
nohup java -jar app_name.jar &
just replace the app_name with your application name and run the command.

How to install Spring boot app on Ubuntu server?

I have Ubuntu server on Digital Ocean and I wrote Spring web app and now I want to put it in production.
I upload it via FTP to the server and I open my console via Putty and I use this command:
java -jar name.jar
Spring is started after that and when I open my web app everything is working fine, but when I close my Putty session my Spring web app does not work anymore. It seems like when I close my Putty session that also Spring web app is closed.
How to solve this?
While what KLHauser suggested will work, but if the vm is restarted in the cloud (which happens) your application will not automatically restart. Also stopping your application with kill -9 is error prone and dangerous, because you accidentally may kill the wrong process.
See running as Linux service section of Spring Boot documentation on how to do that.
If you’ve configured Spring Boot’s Maven or Gradle plugin to generate
a fully executable jar, and you’re not using a custom
embeddedLaunchScript, then your application can be used as an init.d
service. Simply symlink the jar to init.d to support the standard
start, stop, restart and status commands.
The script supports the following features:
Starts the services as the user that owns the jar file
Tracks
application’s PID using /var/run//.pid
Writes
console logs to /var/log/.log
Assuming that you have a Spring Boot application installed in
/var/myapp, to install a Spring Boot application as an init.d service
simply create a symlink:
$ sudo ln -s /var/myapp/myapp.jar /etc/init.d/myapp Once installed,
you can start and stop the service in the usual way. For example, on a
Debian based system:
$ service myapp start
Just use java -jar name.jar & and the application is started in new process thread.
by adding also > log.txt directly at the end you would also have a log.

spring boot run on both windows and linux

I need to run my app on both windows and linux. I started with linux and used spring boot.
I run it simply with:
nohup java -jar ..... &
and I can easily tail the nohup log file.
I can find and kill the process easily too.
How can I do that in windows?
Thanks,
id
Spring Boot 1.3 (about to be released) has many improvements in that area; there is a service support for Unix and Windows.
Check the updated documentation

Why is Spring Boot extremely slow to start up on Mac OSX Mavericks (10.9.2)?

I don't have any other issues with java and STS starts up fine but when I try to run my app as "Run as Spring Boot App" (or any of the samples), the console is empty for up to 5 minutes, before I get the familiar "Spring Boot" ASCII art. Then it works fine.
Turns out there was an issue resolving the network host. I fixed it by executing this command from the console:
scutil --set HostName "localhost"
It must be something with you environment. You may try running the app in other IDE like Intellij. I presume it's the STS causing the problem. You may also try running it in fresh STS installation. I'm using latest OSX and Intellij and have no problems.
If you want to play around with this you could also analyse a java code dump to see what's happening inside your jvm: http://www.javacodegeeks.com/2013/02/analysing-a-java-core-dump.html

Resources