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

网站本地被劫要怎么做查域名备案信息

网站本地被劫要怎么做,查域名备案信息,郑州网站建设行情,网站可以改内链结构吗背景最近项目在jenkins部署的时候发现部署很慢#xff0c;查看部署日志发现kill命令执行后应用pid还存在#xff0c;导致必须在60秒等待期后kill -9杀死springboot进程 应用环境 springboot dependencygroupIdorg.springframework.boot/groupId查看部署日志发现kill命令执行后应用pid还存在导致必须在60秒等待期后kill -9杀死springboot进程 应用环境 springboot dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter/artifactIdversion2.6.3/version /dependencyspringcloud dependencygroupIdcom.alibaba.cloud/groupIdartifactIdspring-cloud-alibaba-dependencies/artifactIdversion2021.0.1.0/versiontypepom/typescopeimport/scope /dependency监控 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactIdversion2.6.3/version /dependency原因分析 通过将全部日志调整为debug级别观察到有个定时任务线程在不断执行例子如下 SpringBootApplication MapperScan(com.test.test.mapper) public class TestApplication implements CommandLineRunner {static ScheduledExecutorService executor;public static void main(String[] args) {executor Executors.newScheduledThreadPool(1);SpringApplication.run(TestApplication.class, args);}private static void run(ScheduledExecutorService executor) {executor.scheduleAtFixedRate(() - {System.out.println(run);}, 0, 1, TimeUnit.SECONDS);Overridepublic void run(String... args) throws Exception {run(executor);} }上述代码中由于线程定义默认是非守护线程执行优雅停机后在用户线程停止后非守护线程不会自动停止 解决办法 定义为守护线程 对于非业务逻辑例如监控数据上传日志记录这样做非常方便但对于系统业务这么做会导致未执行完成任务被丢弃。将线程池定义为springbean交予spring容器管理其生命周期 SpringBootApplication MapperScan(com.test.test.mapper) public class TestApplication implements CommandLineRunner {public static void main(String[] args) {SpringApplication.run(TestApplication.class, args);}private static void run(ScheduledExecutorService executor) {executor.scheduleAtFixedRate(() - {System.out.println(run);}, 0, 1, TimeUnit.SECONDS);}Beanpublic ScheduledExecutorService executor() {return Executors.newScheduledThreadPool(1);}Overridepublic void run(String... args) throws Exception {ScheduledExecutorService executor SpringUtil.getBean(ScheduledExecutorService.class);run(executor);} }效果 弊端此类方式中由于线程池的工作线程属于非守护线程应用会等待所有任务执行完成后才关闭。由于容器已经关闭数据库连接池已经释放这时候任务再获取spring容器内容会报错因此这种方案只适用于用户日志记录监控等非业务功能效果如下 SpringBootApplication MapperScan(com.test.test.mapper) Slf4j public class TestApplication implements CommandLineRunner {public static void main(String[] args) {SpringApplication.run(TestApplication.class, args);}private static void run(ExecutorService executor) {executor.execute(() - {log.info(start);try {TimeUnit.SECONDS.sleep(25);User user SpringUtil.getBean(IUserService.class).findById(10L);log.info(用户信息: user);} catch (Exception ex) {ex.printStackTrace();}log.info(end);});}Beanpublic ExecutorService executor() {return new ThreadPoolExecutor(10, 10, 10, TimeUnit.SECONDS,new ArrayBlockingQueue(1),r - {Thread thread new Thread(r);return thread;},new ThreadPoolExecutor.DiscardOldestPolicy());}Overridepublic void run(String... args) throws Exception {ExecutorService executor SpringUtil.getBean(ExecutorService.class);run(executor);} }3.使用spring提供的ThreadPoolTaskExecutor线程池 SpringBootApplication MapperScan(com.test.test.mapper) Slf4j public class TestApplication implements CommandLineRunner {public static void main(String[] args) {SpringApplication.run(TestApplication.class, args);}private static void run(ThreadPoolTaskExecutor executor) {executor.execute(() - {log.info(start);try {TimeUnit.SECONDS.sleep(25);User user SpringUtil.getBean(IUserService.class).findById(10L);log.info(用户信息: user);} catch (Exception ex) {ex.printStackTrace();}log.info(end);});}Beanpublic ThreadPoolTaskExecutor executor() {int core Runtime.getRuntime().availableProcessors();ThreadPoolTaskExecutor executor new ThreadPoolTaskExecutor();executor.setCorePoolSize(core 3 ? core 1 : core);int maxSize core 2;executor.setMaxPoolSize(maxSize);//使用同步队列避免任务进入等待队列排队导致耗时过长executor.setQueueCapacity(0);executor.setKeepAliveSeconds(30);executor.setWaitForTasksToCompleteOnShutdown(true);executor.setAwaitTerminationSeconds(25);executor.setThreadNamePrefix(async-);executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());executor.initialize();return executor;}Overridepublic void run(String... args) throws Exception {ThreadPoolTaskExecutor executor SpringUtil.getBean(ThreadPoolTaskExecutor.class);run(executor);} }从上图可以看到应用会等待线程池任务执行完毕后才选择优雅关闭因此对于异步业务任务ThreadPoolTaskExecutor才是首选。 spring已经内置了ThreadPoolTaskExecutor 线程池实例我们可以尝试修改其配置参数简化代码来尝试例如 spring:task:execution:pool:queue-capacity: 0core-size: 2max-size: 16keep-alive: 30sthread-name-prefix: async-shutdown:await-termination: trueawait-termination-period: 25sSpringBootApplication MapperScan(com.test.test.mapper) Slf4j public class TestApplication implements CommandLineRunner {public static void main(String[] args) {SpringApplication.run(TestApplication.class, args);}private static void run(ThreadPoolTaskExecutor executor) {executor.execute(() - {log.info(start);try {TimeUnit.SECONDS.sleep(25);User user SpringUtil.getBean(IUserService.class).findById(10L);log.info(用户信息: user);} catch (Exception ex) {ex.printStackTrace();}log.info(end);});}Overridepublic void run(String... args) throws Exception {ThreadPoolTaskExecutor executor SpringUtil.getBean(ThreadPoolTaskExecutor.class);run(executor);} }效果与上述手动创建效果一样但是内置的ThreadPoolTaskExecutor线程池无法通过配置修改拒绝策略rejectedExecutionHandler队列满了之后默认是AbortPolicy会丢弃加入的任务并抛异常spring内置此线程池的初衷在于为定时任务使用例如Scheduled。
http://www.hkea.cn/news/14570495/

相关文章:

  • 如何装修公司网站jsp电商购物网站开发
  • 网站开发技术与应用试验报告4中小微企业税收政策
  • 做相亲网站 一年赚千万wordpress菜单文章列表
  • 做原油的网站seo查询seo优化
  • 懒人凳子网站建设策划书黄骅市网站建设公司
  • 电商网站 投诉建站网站赚钱吗
  • 信誉好的龙岗网站制作wordpress重命名
  • 柳州做网站的公司有哪些订阅号可以做网站链接吗
  • 电子商务网站开发的流程图宁波seo是什么意思
  • 建行移动门户网站相机网站建设策划书
  • 男女做暖暖视频网站html 网站建设中模板
  • 钓鱼转转网站在线生成软件网站开发设计费 怎么入账
  • wordpress中文建站中国国音电商平台官网
  • 建设公司网站的内容西安网站建设方案
  • 北京自助模板建站houzz室内设计官网
  • 网页设计培训班一般多少人seo优化软件哪个好
  • 建设维护网站运营方案网站只做优化
  • 网站制作 火星科技如何做一个网站推广自己的产品
  • 大公司网站建设建网站企业网站实名制
  • 凤冈建设局网站广州建站网络推广公司
  • 昆山网站建设义搏网络优化工作内容
  • 河南省建设网站wordpress主题包下载
  • 建网站一般多少钱什么广告推广最有效果
  • 潇朋友免费班级网站建设系统做网站费用计入什么
  • 网站建设行业新闻做网站都要买服务器吗
  • 怎么查一个网站的外链和反链软件网络工程技术就业前景
  • 局域网视频网站建设微信公众号怎么创建第二个
  • 做网站的客户校园网络建设方案设计
  • 网站建设进度表模板wap网页设计
  • asp网站建设 win7易语言可以做网站吗