从 Eclipse 运行 Tomcat 时如何杀死 Tomcat?

发布于 2024-10-05 22:45:12 字数 162 浏览 3 评论 0原文

我正在运行随 Eclipse 下载一起提供的 Tomcat(不,我不想下载并安装整个 Tomcat),有时它会在停止或重新启动时挂起,我能找到让它工作的唯一方法是重新启动我的所有 Eclipse。我在Windows下使用它。

有什么方法可以终止 Tomcat 进程(它不会出现在任务管理器中)?

I am running the Tomcat that gets delivered with your Eclipse download (no, I don't want to download and install the entire Tomcat), and sometimes it hangs when stopping or restarting, and the only way I can find to make it work is restarting all my Eclipse. I am using it under Windows.

Is there any way to kill the Tomcat process (which doesn't appear in the Task Manager)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

流年里的时光 2024-10-12 22:45:12

它在任务管理器中显示为 javaw.exe。另一种方法是执行 Tomcat/bin/shutdown.bat

至于挂起问题,您确定您的 Web 应用程序不会生成可能阻止 Tomcat 关闭的非托管线程吗?

It appears as javaw.exe in task manager. An alternative is to execute Tomcat/bin/shutdown.bat.

As to the hang problem, are you sure that your webapp isn't spawning unmanaged threads which might be blocking Tomcat's shutdown?

无声静候 2024-10-12 22:45:12

在Windows上,如果你知道Tomcat监听的端口(下面是8080),你可以找到Tomcat进程的PID,然后从cmd中杀死它:

> netstat -aon | find "8080"
  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       2196
  TCP    [::]:8080              [::]:0                 LISTENING       2196
> taskkill /pid 2196 /f
  SUCCESS: The process with PID 2196 has been terminated.

On Windows, if you know the port Tomcat listens to (below, it is 8080), you can find the PID of the Tomcat process and then kill it from cmd:

> netstat -aon | find "8080"
  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       2196
  TCP    [::]:8080              [::]:0                 LISTENING       2196
> taskkill /pid 2196 /f
  SUCCESS: The process with PID 2196 has been terminated.
慈悲佛祖 2024-10-12 22:45:12

当任务管理器中找不到tomcat时,我使用更好的方法来关闭tomcat。

1) 从以下链接下载TCPView(仅285kb)

http://technet.microsoft.com/en-in/sysinternals/bb897437。 aspx

2) 提取文件夹并启动TCPView应用程序。

3) 右键单击​​java.exe并选择结束进程选项。

这会很容易地停止你的tomcat。这个工具在监控端口使用情况方面非常有用。

注意:当 Tomcat 包含某些恶魔或非托管时,运行 TOMCATPATH/bin/shutdown.bat 可能不会关闭 Tomcat
线程。在这种情况下,TCPView 工作正常,没有任何问题。

I use better way to shutdown tomcat when it is not found in task manager.

1) Download TCPView(only 285kb) from following link.

http://technet.microsoft.com/en-in/sysinternals/bb897437.aspx

2) Extract folder and start TCPView application.

3) Right click on java.exe and select End Process option.

this would stop your tomcat easily.. This tool is very useful in monitoring port usage.

NOTE: Running TOMCATPATH/bin/shutdown.bat may not shutdown Tomcat when it contains some demon or unmanaged
threads. In such cases TCPView works fine without any issues.

会傲 2024-10-12 22:45:12

您可以在 Eclipse 中为 Tomcat 服务器设置启动和关闭超时。如果超过这些超时,Eclipse 将弹出一条消息,询问您是否要终止它,还是继续等待。

要设置这些,请双击“服务器”选项卡中的服务器名称。它将打开一个如下窗口:

Eclipse Tomcat 设置

右侧有一个超时部分。我将启动时间设置为一天(这样我就可以在不超时的情况下调试启动),并将关闭时间设置为 30 秒(通常这可能非常短,因为大多数应用程序都可以在强制关闭时正常运行)。

You can set a timeout on startup and shutdown for your Tomcat server in Eclipse. If these timeouts are exceeded, Eclipse will pop up a message asking you if you want to kill it, or keep waiting.

To set these, double-click the name of the server in your Servers tab. It'll open a window like this:

Eclipse Tomcat settings

There's a Timeouts section on the right hand side. I set startup to a day (so I can debug startup without it timing out), and shutdown to 30 seconds to be generous (usually this can be very short, since most apps can survive a forced shutdown with no issues).

梦幻的味道 2024-10-12 22:45:12

如果您使用 Linux,请尝试以下步骤。

  1. 列出 Tomcat 进程(例如,ps aux | grep catalina
  2. 找到如下所示的字符串: myname 2244 5.5 0.3 57020937 2110741 ? Sl Oct03 5160:01 /usr/lib/jvm/java-1.8.0-<...>/bin/java <...> org.apache.catalina.startup.Bootstrap start
  3. 复制粘贴 /usr/lib/jvm/<...><...> 之间的所有内容;.Bootstrap
  4. 在命令末尾添加 stop 并运行它

本质上,您将采用 Eclipse 用来启动 Tomcat 的相同命令并修改最后一个参数来停止 Tomcat 。

If you use Linux, try the following steps.

  1. List Tomcat processes (e.g., ps aux | grep catalina)
  2. Locate the strings that look like this: myname 2244 5.5 0.3 57020937 2110741 ? Sl Oct03 5160:01 /usr/lib/jvm/java-1.8.0-<...>/bin/java <...> org.apache.catalina.startup.Bootstrap start
  3. Copy-paste everything between /usr/lib/jvm/<...> and <...>.Bootstrap
  4. Add stop at the end of your command and run it

Essentially, you would take the very same command that was used by Eclipse to start Tomcat and modify the last argument to stop Tomcat.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文