• Jenkins远程构建项目超时的问题


    目录

    一、问题描述

    二、分析原因


    一、问题描述

    在使用Publish Over SSH进行远程部署项目时一直报如下错:ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after 120,001 ms]

    二、分析原因

    1、日志分析显示超时,于是修改时间,将120000 修改为300000,然后再修改为600000,都没能解决问题,于是排除不是这个问题

     

    2、网上搜索,说是jenkins 启动时候杀掉了build之外的进程,需要在脚本文件加上这句BUILD_ID=dontKillMe,加上之后还是不行。daemon守护线程。还是不行。

    3、有人说是空间不足,于是执行如下命令 清除了一下缓存,还是不行

    1. sync
    2. echo 3 > /proc/sys/vm/drop_caches

    4、后来在服务器手动启动脚本,发现了问题的所在,最后一行,日志输出那行

    原始脚本

    1. #!/bin/bash
    2. source /etc/profile
    3. project=test-wechat-1.0-SNAPSHOT.jar
    4. dir=/opt/deploy/wechat
    5. echo "prepare to deploy test-wechat-1.0-SNAPSHOT"
    6. pid=`ps -ef |grep test-wechat-1.0-SNAPSHOT |grep -v grep| grep 'java' |awk '{print $2}'`
    7. if [[ $pid ]]; then
    8. echo "test-wechat-1.0-SNAPSHOT is running and pid is $pid"
    9. kill -9 $pid
    10. if [[ $? -eq 0 ]];then
    11. echo "sucess to stop test-wechat-1.0-SNAPSHOT"
    12. else
    13. echo "fail to stop test-wechat-1.0-SNAPSHOT"
    14. fi
    15. fi
    16. echo "start to deploy test-wechat-1.0-SNAPSHOT"
    17. cd /opt/deploy/wechat/
    18. nohup java -jar /opt/deploy/wechat/test-wechat-1.0-SNAPSHOT.jar --server.port=9003 >/dev/null 2>&1 &

    发现启动之后一直卡在页面,虽然是后台启动但是并没有出现后台启动的效果

    修改脚本内容如下后,问题解决。

    1. #!/bin/bash
    2. source /etc/profile
    3. project=test-wechat-1.0-SNAPSHOT.jar
    4. dir=/opt/deploy/wechat
    5. echo "prepare to deploy test-wechat-1.0-SNAPSHOT"
    6. pid=`ps -ef |grep test-wechat-1.0-SNAPSHOT |grep -v grep| grep 'java' |awk '{print $2}'`
    7. if [[ $pid ]]; then
    8. echo "test-wechat-1.0-SNAPSHOT is running and pid is $pid"
    9. kill -9 $pid
    10. if [[ $? -eq 0 ]];then
    11. echo "sucess to stop test-wechat-1.0-SNAPSHOT"
    12. else
    13. echo "fail to stop test-wechat-1.0-SNAPSHOT"
    14. fi
    15. fi
    16. echo "start to deploy test-wechat-1.0-SNAPSHOT"
    17. cd /opt/deploy/wechat/
    18. nohup java -jar /opt/deploy/wechat/test-wechat-1.0-SNAPSHOT.jar --server.port=9003 > nohup.out 2>&1 &

     在jenkins配置,一定要添加nohup ,不然项目启动失败

    然后研究了一下日志输出的指令,来源     https://blog.csdn.net/sunrier/article/details/7695839

     不过也还是不太明白为什么没有以后台的方式启动,希望大佬可以一起讨论一下

  • 相关阅读:
    Elasticsearch基础篇(二):Elasticsearch在windows和liunx上的安装部署
    免费SSL证书:JoySSL让您的网站更安全
    Transformer、BERT和GPT 自然语言处理领域的重要模型
    【深度学习】浅显易懂的残差网络(Residual Network)
    《uni-app》表单组件-Label组件
    k8s集群换ip
    数据结构初阶——堆排序
    如何防止ERP实施范围的的扩大
    【管理运筹学】背诵手册(三)| 运输问题
    CUDA与cuDNN安装教程(超详细)
  • 原文地址:https://blog.csdn.net/weixin_39555954/article/details/125598196