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

时间:2018-10-12 15:52:55

标签: java spring spring-boot jhipster spring-boot-actuator

我想用执行器端点关闭我的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..."}

关闭时的日志: enter image description here

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

                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和内存开玩笑的Elasticsearch实例中的本地问题无关。

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

0 个答案:

没有答案