如何仅停止一个应用程序? [英] How to stop only one app?

查看:126
本文介绍了如何仅停止一个应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jetty正在从webapps运行3个站点.其中一个是静态"的有角度的网站,另一个是大型的Java应用程序.

Jetty is running 3 sites from webapps. On of which is a "static" angular site, another is a huge java app.

通常,我使用 Ctrl + c 来停止Jetty,在我的角度站点上进行更改,然后使用以下方式启动Jetty

Typically, I use Ctrl + c to stop Jetty, make changes on my angular site, and start Jetty with

java -jar start.jar -DCommon.properties.path=C:\Jetty

如果我在Jetty运行时尝试编辑文件,则会注入随机的错误代码,从而破坏站点.

If I try to edit the files while Jetty is running, random, buggy code is injected, breaking the site.

因此,此过程非常繁琐. Java应用程序需要15到20秒的加载时间.因此,如果我忘了一个斜杠,则关闭它并重新启动它大约需要一分钟.

So this process is extremely tedious. The java app takes 15-20 seconds to load. So if I forget a slash, it takes about a min to shut it down and restart it.

有没有办法我只能停止/启动webapps之一而不是一次全部停止/启动3个?

Is there a way I can just stop/start only one of the webapps instead of all 3 at once?

推荐答案

您似乎正在使用Windows.

You seem to be using Windows.

您遇到的问题与Microsoft Windows独有的传统上不稳定的FileSystem锁定行为有关(没有其他运行Java的OS会这样做)

The problems you are having relate to the traditionally wonky FileSystem locking behavior that is unique to Microsoft Windows (no other OS that runs Java does this)

请参阅有关此文档的官方文档 https://www.eclipse.org/jetty/documentation/current/troubleshooting-locked-files-on-windows.html

See official documentation about it at https://www.eclipse.org/jetty/documentation/current/troubleshooting-locked-files-on-windows.html

如果您遵循该文档中列出的建议,则无需停止/启动特定的Web应用.

If you follow the advice laid out in that documentation then you'll not need to stop/start a specific webapp.

重要:请注意,文档中的建议仅适用于开发时间,而不是用于生产的良好常规配置.

Important: Note that the advice in the documentation is for DEVELOPMENT TIME ONLY and is not a good general configuration for production.


从OP插入:


Insert from OP:

我按照上面的文档中的说明进行操作,并且成功了!这是我所做的:

I followed the directions in the docs above, and it worked! Here's what I did:

  1. 找到您的webdefault.xml文件.

  1. Find your webdefault.xml file.

  • 矿井位于C:\ Place_where_Jetty_was_installed \ Jetty \ etc \

打开它并搜索UseFileMappedBuffer

查找此: <init-param> <param-name>useFileMappedBuffer</param-name> <param-value>true</param-value> </init-param>

Find this: <init-param> <param-name>useFileMappedBuffer</param-name> <param-value>true</param-value> </init-param>


话虽如此,如果您仍然想走这条路,有两种方法...


That being said, if you still want to go down this path, there's 2 ways ...

1.使用hotreload

为您的重新加载" webapp创建可部署的XML,然后touch仅对1个webapp进行热加载.

Create an XML deployable for your "reload" webapp and touch it to hot reload just that 1 webapp.

文件:${jetty.base}/webapps/myapp.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
          "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/myapp</Set>
  <Set name="war"><Property name="jetty.webapps"/>myapp.war</Set>
</Configure>

然后让码头重新装填...

Then to make jetty reload it just ...

$ touch /path/to/myjettybase/webapps/myapp.xml

此标准Posix命令将更新该文件的时间戳,Jetty将其视为嘿,该文件已更新,我必须重新加载"

This standard Posix command will update the timestamp of that file, which will be seen by Jetty as "hey, that file updated, I must reload it"

2.使用JMX停止/启动特定的Web应用程序

在激活JMX模块(--module=jmx)的情况下启动Jetty.

Start Jetty with the JMX module active (--module=jmx).

启动JMX控制台(JDK随jmcjconsole一起提供)并连接到正在运行的Jetty实例.找到适合您特定Web应用程序的MBean,然后在该特定Web应用程序上使用stop()start()命令.

Start a JMX console (the JDK ships with jmc and jconsole) and connect to your running Jetty instance. Find the MBean for your specific webapp and use the stop() and start() commands on that specific webapp.

这篇关于如何仅停止一个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆