Maven的码头插件 - 延迟在后台模式下启动时(Maven jetty plugin - dela

2019-07-30 11:46发布

我开始使用Linux上的码头服务器

nohup mvn jetty:run &

在后台运行,并留下当我从控制台退出。 通常(MVN码头:运行),它在几秒内启动,但在这种情况下,它需要大约分钟开始。 什么都可以这种延迟的原因是什么?

堆栈跟踪

Full thread dump Java HotSpot(TM) 64-Bit Server VM (11.0-b16 mixed mode):

"Attach Listener" daemon prio=10 tid=0x000000004bba8c00 nid=0x560a waiting on condition [0x0000000000000000..0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Timer-1" daemon prio=10 tid=0x00002aaac053d800 nid=0x55fb in Object.wait() [0x0000000042392000..0x0000000042392b90]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaae554f40> (a java.util.TaskQueue)
        at java.util.TimerThread.mainLoop(Timer.java:509)
        - locked <0x00002aaaae554f40> (a java.util.TaskQueue)
        at java.util.TimerThread.run(Timer.java:462)

"StopJettyPluginMonitor" daemon prio=10 tid=0x00002aaac04b4c00 nid=0x55fa runnable [0x0000000042291000..0x0000000042291b10]
   java.lang.Thread.State: RUNNABLE
        at java.net.PlainSocketImpl.socketAccept(Native Method)
        at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
        - locked <0x00002aaaae453860> (a java.net.SocksSocketImpl)
        at java.net.ServerSocket.implAccept(ServerSocket.java:453)
        at java.net.ServerSocket.accept(ServerSocket.java:421)
        at org.mortbay.jetty.plugin.util.Monitor.run(Monitor.java:74)

"Timer-0" daemon prio=10 tid=0x000000004b5cf800 nid=0x55f9 in Object.wait() [0x0000000040c78000..0x0000000040c78a90]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaaeea00b8> (a java.util.TaskQueue)
        at java.util.TimerThread.mainLoop(Timer.java:509)
        - locked <0x00002aaaaeea00b8> (a java.util.TaskQueue)
        at java.util.TimerThread.run(Timer.java:462)

"1455093129@qtp-422797318-1 - Acceptor0 SelectChannelConnector@0.0.0.0:8080" prio=10 tid=0x000000004b6d9800 nid=0x55f7 runnable [0x000000004130c000..0x000000004130ca10]
   java.lang.Thread.State: RUNNABLE
        at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
        at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:215)
        at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:65)
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)
        - locked <0x00002aaaae44ac10> (a sun.nio.ch.Util$1)
        - locked <0x00002aaaae44abf8> (a java.util.Collections$UnmodifiableSet)
        - locked <0x00002aaaae44a588> (a sun.nio.ch.EPollSelectorImpl)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
        at org.mortbay.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:459)
        at org.mortbay.io.nio.SelectorManager.doSelect(SelectorManager.java:192)
        at org.mortbay.jetty.nio.SelectChannelConnector.accept(SelectChannelConnector.java:124)
        at org.mortbay.jetty.AbstractConnector$Acceptor.run(AbstractConnector.java:706)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)

"91446054@qtp-422797318-0" prio=10 tid=0x000000004b621400 nid=0x55f6 in Object.wait() [0x000000004120b000..0x000000004120bd90]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaab1171890> (a org.mortbay.thread.QueuedThreadPool$PoolThread)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:563)
        - locked <0x00002aaab1171890> (a org.mortbay.thread.QueuedThreadPool$PoolThread)

"pool-1-thread-5" prio=10 tid=0x00002aaac15d4c00 nid=0x55f5 in Object.wait() [0x0000000041a4f000..0x0000000041a4fd10]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at java.lang.Object.wait(Object.java:485)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:316)
        - locked <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:994)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1054)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
        at java.lang.Thread.run(Thread.java:619)

"pool-1-thread-4" prio=10 tid=0x00002aaac0134000 nid=0x55f4 in Object.wait() [0x000000004194e000..0x000000004194ec90]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at java.lang.Object.wait(Object.java:485)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:316)
        - locked <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:994)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1054)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
        at java.lang.Thread.run(Thread.java:619)

"pool-1-thread-3" prio=10 tid=0x000000004ba72800 nid=0x55f3 in Object.wait() [0x0000000042190000..0x0000000042190c10]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at java.lang.Object.wait(Object.java:485)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:316)
        - locked <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:994)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1054)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
        at java.lang.Thread.run(Thread.java:619)

"pool-1-thread-2" prio=10 tid=0x000000004b8b6c00 nid=0x55f2 in Object.wait() [0x000000004208f000..0x000000004208fb90]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at java.lang.Object.wait(Object.java:485)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:316)
        - locked <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:994)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1054)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
        at java.lang.Thread.run(Thread.java:619)

"pool-1-thread-1" prio=10 tid=0x000000004b8b6400 nid=0x55f1 in Object.wait() [0x0000000040415000..0x0000000040415b10]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at java.lang.Object.wait(Object.java:485)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:316)
        - locked <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:994)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1054)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
        at java.lang.Thread.run(Thread.java:619)

"Low Memory Detector" daemon prio=10 tid=0x000000004affd800 nid=0x55eb runnable [0x0000000000000000..0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"CompilerThread1" daemon prio=10 tid=0x000000004affb800 nid=0x55ea waiting on condition [0x0000000000000000..0x0000000041d8b4d0]
   java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=10 tid=0x000000004aff7800 nid=0x55e9 waiting on condition [0x0000000000000000..0x0000000041c8a450]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x000000004aff5c00 nid=0x55e8 runnable [0x0000000000000000..0x0000000041b8a820]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=10 tid=0x000000004afd2400 nid=0x55e7 in Object.wait() [0x000000004184d000..0x000000004184db10]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafdf0450> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
        - locked <0x00002aaaafdf0450> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x000000004afd0800 nid=0x55e6 in Object.wait() [0x000000004174c000..0x000000004174ca90]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafdf0530> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:485)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
        - locked <0x00002aaaafdf0530> (a java.lang.ref.Reference$Lock)

"main" prio=10 tid=0x000000004af6e000 nid=0x55e4 in Object.wait() [0x000000004072f000..0x0000000040730ed0]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaab1196b60> (a org.mortbay.thread.QueuedThreadPool$Lock)
        at java.lang.Object.wait(Object.java:485)
        at org.mortbay.thread.QueuedThreadPool.join(QueuedThreadPool.java:298)
        - locked <0x00002aaab1196b60> (a org.mortbay.thread.QueuedThreadPool$Lock)
        at org.mortbay.jetty.plugin.Jetty6PluginServer.join(Jetty6PluginServer.java:206)
        at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:461)
        at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
        at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
        at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:553)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:523)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

"VM Thread" prio=10 tid=0x000000004afcb000 nid=0x55e5 runnable

"VM Periodic Task Thread" prio=10 tid=0x000000004b000000 nid=0x55ec waiting on condition

JNI global references: 861

Answer 1:

我得到这么看腻人滥用nohup 。 这里的系统守护进程程序如何真正的工作:

  1. 创建子进程。
  2. 启动守护进程作为子进程的一个孩子。
  3. 退出第一个进程。

一个简单的方法来模拟这种使用sh如下。

sh -c "mvn jetty:run &"

观察...

scott@optimusprime:~/code/leapfrog/lasso> sh -c "mvn jetty:run &"
scott@optimusprime:~/code/leapfrog/lasso> ps aux | grep jetty:run
scott    26165 45.5  5.8 813556 235764 pts/9   Sl   15:23   0:06 /usr/lib/jvm/java-6-sun//bin/java -Xmx512M -classpath /home/scott/opt/apache-maven-2.2.1//boot/classworlds-1.1.jar -Dclassworlds.conf=/home/scott/opt/apache-maven-2.2.1//bin/m2.conf -Dmaven.home=/home/scott/opt/apache-maven-2.2.1/ org.codehaus.classworlds.Launcher "jetty:run"
scott@optimusprime:~/code/leapfrog/lasso> exit

如果我从一个单独的终端,或稍后检查我的进程列表,程序仍在运行。

但是我要问,为什么这样做,而不是只安装在本地的应用程序服务器的Web应用程序,并开始了吗? 希望你不管理使用Apache Maven的你的真实环境。



Answer 2:

我会在前台运行,并引发线程转储(Ctrl + Break),看看它是通过检查每个线程的堆栈跟踪做的事情。 没有任何进一步的信息,我不能提供任何更多的建议。



Answer 3:

我建议您尝试使用screen 。 可能是矫枉过正这样一个简单的任务,但你可以在shell脚本包裹。



Answer 4:

使用Maven是非常方便的下载,安装和启动应用程序。 在许多其他好处,行家为开发人员提供管理码头的版本的功能。 使用此提供我想行家符合该法案作为生产启动机制的建议。



文章来源: Maven jetty plugin - delay when starting in background mode