jenkins执行nohup命令后台启动后,程序直接挂掉解决方案

本文介绍如何在Shell脚本中设置BUILD_ID=dontKillMe来防止Jenkins构建完成后杀死指定进程。通过修改BUILD_ID属性,Jenkins将无法识别该进程为构建衍生进程,从而允许其在后台继续运行。
部署运行你感兴趣的模型镜像

在shell脚本中加入BUILD_ID=dontKillMe

#!/bin/bash
BUILD_ID=dontKillMe
nohup java -jar kevin-eureka-0.0.1-SNAPSHOT.jar >> nohup.out &

原理:jenkins默认会在构建完成后杀掉构建过程中shell命令触发的衍生进程。jenkins根据BUILD_ID识别某个进程是否为构建过程的衍生进程,故修改BUILD_ID后,jenkins就无法识别是否为衍生进程,则此进程能在后台保留运行。

您可能感兴趣的与本文相关的镜像

Llama Factory

Llama Factory

模型微调
LLama-Factory

LLaMA Factory 是一个简单易用且高效的大型语言模型(Large Language Model)训练与微调平台。通过 LLaMA Factory,可以在无需编写任何代码的前提下,在本地完成上百种预训练模型的微调

Started by user liuling [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in /Users/ios/.jenkins/workspace/android-appium-test [Pipeline] { [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (Declarative: Tool Install) [Pipeline] tool [Pipeline] envVarsForTool [Pipeline] } [Pipeline] // stage [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (Scan Android Devices) [Pipeline] tool [Pipeline] envVarsForTool [Pipeline] withEnv [Pipeline] { [Pipeline] script [Pipeline] { [Pipeline] echo 开始扫描连接的 Android 设备... [Pipeline] sh + adb devices [Pipeline] echo adb devices 输出为: List of devices attached 192.168.1.43:5555 device emulator-5554 device [Pipeline] echo 检测到 2 台设备: 192.168.1.43:5555, emulator-5554 [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Start Appium Servers) [Pipeline] tool [Pipeline] envVarsForTool [Pipeline] withEnv [Pipeline] { [Pipeline] script [Pipeline] { [Pipeline] sh + lsof -i :4723 + grep LISTEN node 34850 ios 16u IPv4 0x3597b850efd609a0 0t0 TCP *:4723 (LISTEN) [Pipeline] echo 端口 4723 已被占用,尝试下一个... [Pipeline] sh + lsof -i :4725 + grep LISTEN [Pipeline] echo 找到空闲端口: 4725 [Pipeline] echo 为设备 192.168.1.43:5555 分配 Appium 端口 4725 [Pipeline] sh + echo 51496 + nohup appium -a 0.0.0.0 -p 4725 --allow-cors --session-override + sleep 3 + echo '📄 日志内容(启动阶段):' 📄 日志内容(启动阶段): + cat appium_192.168.1.43:5555.log [Appium] Welcome to Appium v3.1.0 [Appium] Non-default server args: [Appium] { allowCors: true, port: 4725, sessionOverride: true } [Appium] The autodetected Appium home path: /Users/ios/.appium [Appium] Attempting to load driver xcuitest... [Appium] Attempting to load driver uiautomator2... [Appium] Requiring driver at /Users/ios/.appium/node_modules/appium-xcuitest-driver/build/index.js [Appium] XCUITestDriver has been successfully loaded in 0.520s [Appium] Requiring driver at /Users/ios/.appium/node_modules/appium-uiautomator2-driver/build/index.js [Appium] AndroidUiautomator2Driver has been successfully loaded in 0.997s [Appium] You have enabled CORS requests from any host. Be careful not to visit sites which could maliciously try to start Appium sessions on your machine [Appium] Appium REST http interface listener started on http://0.0.0.0:4725 [Appium] You can provide the following URLs in your client code to connect to this server: http://127.0.0.1:4725/ (only accessible from the same host) http://192.168.137.29:4725/ http://192.168.1.142:4725/ [Appium] Available drivers: [Appium] - xcuitest@10.2.1 (automationName 'XCUITest') [Appium] - uiautomator2@6.6.2 (automationName 'UiAutomator2') [Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use. + sleep 10 + echo '📄 日志内容(崩溃阶段,关键!):' 📄 日志内容(崩溃阶段,关键!): + cat appium_192.168.1.43:5555.log [Appium] Welcome to Appium v3.1.0 [Appium] Non-default server args: [Appium] { allowCors: true, port: 4725, sessionOverride: true } [Appium] The autodetected Appium home path: /Users/ios/.appium [Appium] Attempting to load driver xcuitest... [Appium] Attempting to load driver uiautomator2... [Appium] Requiring driver at /Users/ios/.appium/node_modules/appium-xcuitest-driver/build/index.js [Appium] XCUITestDriver has been successfully loaded in 0.520s [Appium] Requiring driver at /Users/ios/.appium/node_modules/appium-uiautomator2-driver/build/index.js [Appium] AndroidUiautomator2Driver has been successfully loaded in 0.997s [Appium] You have enabled CORS requests from any host. Be careful not to visit sites which could maliciously try to start Appium sessions on your machine [Appium] Appium REST http interface listener started on http://0.0.0.0:4725 [Appium] You can provide the following URLs in your client code to connect to this server: http://127.0.0.1:4725/ (only accessible from the same host) http://192.168.137.29:4725/ http://192.168.1.142:4725/ [Appium] Available drivers: [Appium] - xcuitest@10.2.1 (automationName 'XCUITest') [Appium] - uiautomator2@6.6.2 (automationName 'UiAutomator2') [Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use. [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (1/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (2/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (3/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (4/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (5/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (6/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (7/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (8/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (9/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (10/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (11/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (12/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (13/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (14/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (15/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (16/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (17/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (18/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (19/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] sh + curl -s http://0.0.0.0:4725/wd/hub/status + grep '"ready":true' + true [Pipeline] echo aiting for Appium on port 4725... (20/20) [Pipeline] sleep Sleeping for 3 sec [Pipeline] error [Pipeline] } [Pipeline] // script [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: ppium on port 4725 did not become ready Finished: FAILURE两次抓取其appium端口存在,并且在curl期间也存在,curl验证失败之后,命令行验证,这个端口就不存在了
最新发布
12-27
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值