繁体   English   中英

弹簧执行器关闭端点无法停止Java进程

Spring actuator shutdown-endpoint cannot stop java process

提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供   中文繁体   英文版本   中英对照 版本,有任何建议请联系yoyou2525@163.com。

我想使用执行器端点关闭我的spring boot应用程序(spring boot v2)。 我已经使用spring-actuator成功启用了关闭端点(请参阅application.yml)。 我还可以调用端点,然后spring关闭应用程序上下文(请参阅logs和curl命令)。

但是以某种方式,Java进程并没有被杀死。 我还尝试将应用程序打包到docker容器中,以确保它不是Java的本地安装问题。 但没有成功-Java进程仍在运行。

该应用程序以H2数据库和用于Elasticsearch的Spring-Data-Jest的开发模式启动。

application.yml

management:
    security:
        roles: ADMIN
    endpoints:
        web:
            base-path: /management
            exposure:
                include: ["configprops", "env", "health", "info", "threaddump", "logfile", "shutdown" ]
    endpoint:
        health:
            show-details: when_authorized
        shutdown:
            enabled: true
    info:
        git:
            mode: full
    health:
        mail:
            enabled: false # When using the MailService, configure an SMTP server and set this to true
    metrics:
        enabled: false # http://micrometer.io/ is disabled by default, as we use http://metrics.dropwizard.io/ instead

spring:
    autoconfigure:
        exclude: org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration,org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration
    application:
        name: AnyWEB
    profiles:
        # The commented value for `active` can be replaced with valid Spring profiles to load.
        # Otherwise, it will be filled in by gradle when building the WAR file
        # Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS`
        active: #spring.profiles.active#
    jpa:
        open-in-view: false
        hibernate:
            ddl-auto: none
            naming:
                physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
                implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
    messages:
        basename: i18n/messages
    mvc:
        favicon:
            enabled: false
    thymeleaf:
        mode: HTML

server:
    servlet:
        session:
            cookie:
                http-only: true

info:
    # Comma separated list of profiles that will trigger the ribbon to show
    display-ribbon-on-profiles: "dev"

jhipster:
    async:
        core-pool-size: 2
        max-pool-size: 50
        queue-capacity: 10000
    # By default CORS is disabled. Uncomment to enable.
    #cors:
        #allowed-origins: "*"
        #allowed-methods: "*"
        #allowed-headers: "*"
        #exposed-headers: "Authorization,Link,X-Total-Count"
        #allow-credentials: true
        #max-age: 1800
    mail:
        from: AnyWEB@localhost
    swagger:
        default-include-pattern: /api/.*
        title: AnyWEB API
        description: AnyWEB API documentation
        version: 0.0.1
        terms-of-service-url:
        contact-name:
        contact-url:
        contact-email:
        license:
        license-url:

logging:
    file: build/AnyWEB.log

CURL关闭端点

curl --header "Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImF1dGgiOiJST0xFX0FETUlOLFJPTEVfVVNFUiIsImV4cCI6MTUzOTQzNTk0OX0.tlu88esl-PYzdZvdEnlaJJB2Niy4p2AOtHqL5O7tr1C2LDottIZJtZGAi2WLTW9VYKUScY-eDi3P7TxhndS6CA" -X POST 192.168.99.100:8080/management/shutdown
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    35    0    35    0     0     66      0 --:--:-- --:--:-- --:--:--    66{"message":"Shutting down, bye..."}

关闭时的日志: 在此处输入图片说明

这是调用执行器关闭端点后的完整线程转储

Full thread dump

                "XNIO-1 Accept@7046" daemon prio=5 tid=0x17 nid=NA runnable
                  java.lang.Thread.State: RUNNABLE
                      at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(WindowsSelectorImpl.java:-1)
                      at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
                      at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
                      at sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
                      at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
                      - locked  (a sun.nio.ch.WindowsSelectorImpl)
                      - locked  (a java.util.Collections$UnmodifiableSet)
                      - locked  (a sun.nio.ch.Util$2)
                      at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
                      at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:101)
                      at org.xnio.nio.WorkerThread.run(WorkerThread.java:511)

                "XNIO-1 I/O-1@7045" daemon prio=5 tid=0x16 nid=NA runnable
                  java.lang.Thread.State: RUNNABLE
                      at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll0(WindowsSelectorImpl.java:-1)
                      at sun.nio.ch.WindowsSelectorImpl$SubSelector.poll(WindowsSelectorImpl.java:296)
                      at sun.nio.ch.WindowsSelectorImpl$SubSelector.access$400(WindowsSelectorImpl.java:278)
                      at sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:159)
                      at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
                      - locked  (a sun.nio.ch.WindowsSelectorImpl)
                      - locked  (a java.util.Collections$UnmodifiableSet)
                      - locked  (a sun.nio.ch.Util$2)
                      at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
                      at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:101)
                      at org.xnio.nio.WorkerThread.run(WorkerThread.java:511)

                "pool-4-thread-1@19750" prio=5 tid=0x3b nid=NA waiting
                  java.lang.Thread.State: WAITING
                      at sun.misc.Unsafe.park(Unsafe.java:-1)
                      at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
                      at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
                      at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
                      at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
                      at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                      at java.lang.Thread.run(Thread.java:745)

                "Abandoned connection cleanup thread@6449" daemon prio=5 tid=0x15 nid=NA waiting
                  java.lang.Thread.State: WAITING
                      at sun.misc.Unsafe.park(Unsafe.java:-1)
                      at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
                      at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
                      at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
                      at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                      at java.lang.Thread.run(Thread.java:745)

                "MVStore background writer nio:C:/Users/Simon/git/lisaweb/build/h2db/db/lisaweb.mv.db@7366" daemon prio=5 tid=0x19 nid=NA waiting
                  java.lang.Thread.State: WAITING
                      at java.lang.Object.wait(Object.java:-1)
                      at org.h2.mvstore.MVStore$BackgroundWriterThread.run(MVStore.java:2708)

                "Finalizer@19938" daemon prio=8 tid=0x3 nid=NA waiting
                  java.lang.Thread.State: WAITING
                      at java.lang.Object.wait(Object.java:-1)
                      at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
                      at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
                      at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

                "Reference Handler@19939" daemon prio=10 tid=0x2 nid=NA waiting
                  java.lang.Thread.State: WAITING
                      at java.lang.Object.wait(Object.java:-1)
                      at java.lang.Object.wait(Object.java:502)
                      at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
                      at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)

                "DestroyJavaVM@19830" prio=5 tid=0x42 nid=NA runnable
                  java.lang.Thread.State: RUNNABLE

                "Attach Listener@19936" daemon prio=5 tid=0x5 nid=NA runnable
                  java.lang.Thread.State: RUNNABLE

                "Signal Dispatcher@19937" daemon prio=9 tid=0x4 nid=NA runnable
                  java.lang.Thread.State: RUNNABLE

更新:我已经在docker中运行了带有mysql + elasticsearch的生产环境。 我使用生产配置文件启动了该应用程序,但仍然存在相同的问题。 所以我想这与局部h2和局部内存jest elasticsearch实例无关。

任何帮助将不胜感激-谢谢

问题暂未有回复.您可以查看右边的相关问题.
1 弹簧启动执行器/关闭端点禁止

我第一次使用Spring Boot应用程序时,执行器已不安全,因此很容易通过/ actuator / shutdown端点远程关闭。 最近,我已经使用Spring安全保护了我的执行器,并且它已经起作用了。 现在,我需要提供http基本凭据来访问端点,但是现在对/ actuator / shu ...

6 无法更改弹簧执行器端口

我的应用程序在端口8444上运行,但是我希望我的执行器指标公开给其他端口,默认情况下,我可以通过https:// localhost:8444 / actuator / health访问它们,但我希望它们在诸如8086的其他端口上 https://docs.spring.io/spring-boo ...

10 弹簧启动执行器端点未激活

我正在学习 Spring Boot Actuator,请注意 Spring Boot 执行器没有被激活。 我正在关注文档 [spring docs][1],因此添加了提到的 maven 依赖项。 我的 POM.xml: 我的春季申请: 应用程序属性 控制台输出: 我正在尝试访问h ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2022 STACKOOM.COM