当前位置: 首页 > news >正文

我的世界怎么做充值点卷网站厦门网站设计公司找哪家厦门小程序建设

我的世界怎么做充值点卷网站,厦门网站设计公司找哪家厦门小程序建设,wordpress更改绑定域名,华安县城乡规划建设局网站一、目的 服务发生线程锁住#xff0c;需要下线服务时#xff0c;保证请求中的接口不受影响#xff0c;执行完后#xff0c;再下线服务 二、步骤 *kill -15时执行改钩子函数 优雅停机 1.当线程锁住 2.运维那边监控到#xff0c;然后进行kill -15 进程ID 3.代码这边监…一、目的 服务发生线程锁住需要下线服务时保证请求中的接口不受影响执行完后再下线服务 二、步骤 *kill -15时执行改钩子函数 优雅停机 1.当线程锁住 2.运维那边监控到然后进行kill -15 进程ID 3.代码这边监听到关闭信号先把容器权重设置为0不允许新的请求进来. 4.然后为了保住容器其他请求中的接口不受影响进行睡眠30s再关闭容器 三、代码实现 package com.dst.XXX.XXX;import com.alibaba.cloud.nacos.NacosDiscoveryProperties; import com.alibaba.nacos.api.NacosFactory; import com.alibaba.nacos.api.PropertyKeyConst; import com.alibaba.nacos.api.exception.NacosException; import com.alibaba.nacos.api.naming.NamingService; import com.alibaba.nacos.api.naming.pojo.Instance; import com.dst.steed.common.util.DstSpringUtil; import com.dst.steed.rabbit.annotation.SteedAmqpScan; import lombok.extern.slf4j.Slf4j; import org.mybatis.spring.annotation.MapperScan; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.util.StopWatch;import javax.annotation.Resource; import java.text.DecimalFormat; import java.util.List; import java.util.Optional; import java.util.Properties;import static com.dst.lcb.base.DstSteedLcbBaseService.PACKAGE_NAME;/*** 服务启动** author LWP* since 2024/08/20*/ Slf4j SpringBootApplication(scanBasePackages {PACKAGE_NAME}) EnableFeignClients(basePackages PACKAGE_NAME .infrastructure.acl) MapperScan(basePackages {PACKAGE_NAME .infrastructure.biz.**.mapper, PACKAGE_NAME .modules.mapper,generator.mapper}) SteedAmqpScan(basePackage PACKAGE_NAME .infrastructure.mq) public class DstSteedXXXXService implements CommandLineRunner, ApplicationContextAware {public static final String PACKAGE_NAME com.dst.XXX.XXX;Autowiredprivate ConfigurableApplicationContext applicationContext;Resourceprivate NacosDiscoveryProperties nacosDiscoveryProperties;public static void main(String[] args) {StopWatch stopWatch new StopWatch();stopWatch.start();SpringApplication.run(DstSteedLcbBaseService.class, args);stopWatch.stop();log.info(【服务 DstSpringUtil.getAppName() 环境 DstSpringUtil.getActiveProfile() 】启动成功耗时 new DecimalFormat(#.##).format(stopWatch.getTotalTimeSeconds()) 秒。);}/*** kill -15时执行改钩子函数 优雅停机* 1.线程锁住* 2.运维那边监控到然后进行kill -15 进程ID* 3.代码这边监听到关闭信号先把容器权重设置为0不允许新的请求进来.* 4.然后为了保住容器其他请求中的接口不受影响进行睡眠30s再关闭容器*/Overridepublic void run(String... args) {log.info(启动成功 !);Runtime.getRuntime().addShutdownHook(new Thread(() - {log.info(收到服务关闭信号);stop();try {log.info(睡眠30秒);Thread.sleep(30000);} catch (InterruptedException e) {throw new RuntimeException(e);}applicationContext.close();}));}private void stop() {try {Properties properties new Properties();properties.put(PropertyKeyConst.NAMESPACE, nacosDiscoveryProperties.getNamespace());properties.put(PropertyKeyConst.SERVER_ADDR, nacosDiscoveryProperties.getServerAddr());NamingService namingService NacosFactory.createNamingService(properties);String serviceName nacosDiscoveryProperties.getService();ListInstance instanceList namingService.getAllInstances(serviceName);OptionalInstance currentInstance instanceList.stream().filter(instance - instance.getIp().equals(nacosDiscoveryProperties.getIp())).findFirst();currentInstance.ifPresent(instance - {log.info(找到当前服务实例: {}, instance);instance.setWeight(0);try {namingService.registerInstance(serviceName, instance);log.info(Nacos 服务权重已设置为 0);} catch (NacosException e) {log.error(设置 Nacos 服务权重时发生错误, e);}});} catch (NacosException e) {log.error(获取 Nacos 命名服务时发生错误, e);}}Overridepublic void setApplicationContext(ApplicationContext applicationContext) {if (applicationContext instanceof ConfigurableApplicationContext) {this.applicationContext (ConfigurableApplicationContext) applicationContext;}}}
http://www.dnsts.com.cn/news/151698.html

相关文章:

  • 网站建站所用的技术韩文网站建设
  • 怎样申请注册公司网站淘宝api wordpress
  • 新乡做网站推广公司网站后台维护
  • 英文网站开发哪家好wordpress grace7 破解
  • 制作网站首页教案找人一起做素材网站
  • 专业做酒类营销的网站网络推广策划思路
  • 深圳网站建设效果汕头建站免费模板
  • 珠江新城网站建设北京高端品牌网站建设
  • 湖州住房和城乡建设厅网站有个网站做字的图片
  • 有经验的郑州网站建设石家庄做外贸网站建设
  • 网站怎样建设网站套用模板
  • 国内做网站建设好的拼多多网站建设
  • 在大网站做网页广告需要多少钱中国科技成就ppt
  • uemo网站平台建设wordpress 安装php
  • 汕头企业制作网站推广怎么修改自己网站内容
  • 厦门网站制作系统庆阳网站建设公司
  • html5网站设计造价员报考官网
  • wordpress全站网易云音乐播放下载wordpress很慢
  • 网站建设交印花税股票app开发价格
  • 中国农村建设网站首页网页设计参考网站
  • 关于申请建设网站的请示网站做链接的意义是什么
  • 网站更换服务器 备案黄石网站建设多少钱
  • 金融投资风险公司网站源码如何开拓海外市场
  • 外贸网站品牌官网建设中国外贸网站排名
  • 建站成本网站建设学徒
  • 南昌企业建设网站设计下载可以做动漫的我的世界视频网站
  • 网站怎么做转发网络营销的功能是什么?
  • 如何了解和掌握一个网站的权重上海网商电子商务有限公司
  • 苏州网站建设如何选择wordpress各个页面名称标签
  • 网站视觉规范wordpress主题付费吗