What is the best way to stop a Grails application started with:
nohup java -jar myapp.war --server-port=9090 &
What is the best way to stop a Grails application started with:
nohup java -jar myapp.war --server-port=9090 &
Get the process ID:
ps -A | grep java
If the process id 3114
for example, then stop the process:
kill 3114
Sometimes, Grails app doesn't kill cleanly, then use:
kill -9 3114
Optionally, in one of your action in the controller, you can simply write:
System.exit()
This is the convenient way to shutdown your Grails application which will properly execute all your Shutdown hooks and will cleanly shutdown your app by preventing memory links, releasing resources, closing any streams extra.
killall -9 java
or
killall -15 java
That's it ! This command sends signals to processes identified by their name.
-9
or -15
?Because you use nohup
which prevents the processes from receiving SIGHUP
. So, you must use -15 (SIGTERM
) or -9 (SIGKILL
) with kill command.