服务停止时未执行Vertx停止方法



当我停止服务时,停止不会被调用,但如果在测试用例中尝试相同的操作,即我使用部署ID部署和取消部署vertical,则停止方法正在执行。

编辑:-我正在创建jar文件(而不是影子jar(。以下是build.gradle配置

application{
mainClassName='io.vertx.core.Launcher'
}
def mainVerticleName = 'verticleName'
jar {
manifest {
attributes(
"Manifest-Version": "1.0",
"Main-Verticle": "$mainVerticleName",
"Main-Class": "io.vertx.core.Launcher",
"Class-Path": configurations.runtimeClasspath.collect { it.getName() }.join(' ')
)
}
}

启动应用程序:-

java -jar api-gateway-1.0.0-SNAPSHOT.jar -Dconfig.propertyFile="<property file path>" -DlogfilePath="<log file path>"

停止应用程序:-

CTRL+C

创建CustomLauncher扩展Launcher类成功。

@Log4j2
public class CustomLauncher extends Launcher {

public static void main(String[] args) {
new CustomLauncher().dispatch(args);
}
@Override
public void beforeStoppingVertx(Vertx vertx) {
log.info(" beforeStoppingVertx Called ===========");
cleanUPBeforeStoppingVerx();
}
@Override
public void afterStoppingVertx() {
log.info(" afterStoppingVertx Called ===========");
}
@Override
public void beforeDeployingVerticle(DeploymentOptions deploymentOptions) {
log.info(" beforeDeployingVerticle Called ===========");
}
@Override
public void beforeStartingVertx(VertxOptions options) {
log.info(" beforeStartingVertx Called ===========");
}

@Override
public void afterStartingVertx(Vertx vertx) {
log.info(" afterStartingVertx Called ===========");
}
@Override
public void handleDeployFailed(Vertx vertx, String mainVerticle, DeploymentOptions deploymentOptions,
Throwable cause) {
log.info("handleDeployFailed *****************");
vertx.close();
}
}

build.gradle更改:-

jar {
manifest {
attributes(
"Manifest-Version": "1.0",
"Main-Verticle": "LauncherVerticle",
"Main-Class": "CustomLauncher",
"Class-Path": configurations.runtimeClasspath.collect { it.getName() }.join(' ')
)
}
}

相关内容

  • 没有找到相关文章

最新更新