Reputation: 65
I work on huge repositories linked to my java project (running on Eclipse) and sometimes (when I do text search usually), my Eclipse stops working.
If I "hard close" it in that state and if I have my Tomcat started, the problem is that it will not stop tomcat before exiting.
When I launch Eclipse again, it will show me that Tomcat is stopped (it is not because it didn't stop tomcat when I hard closed Eclipse), and if I try to launch it again I have the following error :
The only way for me to restart it is to reboot my computer.. I admit that it is a bit annoying..
Do you know if there is a way to stop my "phantom-running" tomcat server in Eclipse or do I have to restart my computer everytime it happens ? (I don't have admin rights on my computer, I can't use the task manager to kill process)
Many thanks
Upvotes: 1
Views: 787
Reputation: 15663
The standard mechanism to stop tomcat is to send a shutdown command on the shutdown port. Usually the shutdown port is 8005. You can stop the server by sending the command manually:
echo "SHUTDOWN" | nc -w 2 127.0.01 8005
SHUTDOWN
If you do not have access to those commands, you can write a simple app in java:
public static void main(String[] args) throws IOException {
final InetSocketAddress shutdownAddress = new InetSocketAddress(Inet4Address.getLoopbackAddress(), 8005);
try (Socket socket = new Socket()) {
socket.connect(shutdownAddress);
try (OutputStream out = socket.getOutputStream()) {
out.write("SHUTDOWN".getBytes(StandardCharsets.US_ASCII));
}
}
}
PS: On linux you can also send signal SIG_INT: kill -2 <PID>
Upvotes: 1