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

企业网站改版的意义贵阳做网站需要多少钱

企业网站改版的意义,贵阳做网站需要多少钱,域名比价网,宣传片制作软件一、目的 服务发生线程锁住#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/167029.html

相关文章:

  • 如何使用花生壳做网站旅游网络营销的渠道有哪些
  • 做网站什么最重要北京厦门网站优化
  • 如何让网站排名下降app ui设计网站
  • 网站重新搭建程序要多少钱计算机网络 网站开发与设计
  • 网站建设案例查询ui设计风格
  • 重庆福彩建站wordpress跳转下载页面
  • 网站建设怎么建好洛阳网站建设哪个好点
  • 博客网站怎么做cpa机械做网站好处
  • 站长工具官方网wordpress 媒体插件
  • 云主机 多 网站哪家的装修公司比较好
  • 做网站还需要兼容ie6吗泰安北京网站建设公司哪家好
  • 江西医院网站建设代做网站名称优化
  • html商城网站模板下载沈阳建设工程信息网官方网站
  • 坪地网站建设代理商wordpress链接里的图像地址
  • 网站模板如何优化深圳做响应式网站
  • 网站后台管理系统html江苏省建设招标网站
  • 局网站建设招标常见的网站推广方案
  • 建立网站的技术路径wordpress ajax 分页插件
  • wordpress导航字体清远seo站内优化
  • 常用的网站推广网站推广策划的思路
  • 深紫色网站营销推广是干什么的
  • 石家庄整站优化技术怎么给网站加代码
  • 旅游电子商务网站建设的重要性站长工具手机综合查询
  • 中英语双语网站咋做蛋糕店网站模板
  • 网站建立计划书网站空间和域名价格
  • 做网站建设专业定制代做网站公司
  • 做网站的标签及属性一般做网站用什么字体比较合适
  • 常宁网站建设常宁网站建设seo工作
  • 网站备案初审时间有没有那种帮人做ppt的网站
  • 甘肃省住房和城乡建设厅网站职称证查询企业网站欣赏