You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

寻求可监控应用进程是否无响应或挂起的Jenkins插件

Solutions for Monitoring and Restarting Unresponsive Apps in Jenkins

Hey there! I’ve run into similar headaches with unresponsive applications during Jenkins testing, so I’ll share some practical plugins and workarounds that should help you skip the long waits for timeouts to kick in.

1. Process Monitor Plugin

This plugin is tailor-made for tracking process health. You can configure it to:

  • Monitor specific processes by name or PID
  • Set thresholds for CPU/memory usage, or flag lack of process activity (a telltale sign of a hang)
  • Automatically trigger process termination and restart actions the moment a hang is detected

It eliminates the waiting time entirely—no more sitting around for a fixed timeout. Just set up health check rules that match your app’s normal behavior, and let the plugin handle restarts when things go south.

2. Build Timeout Plugin (Advanced Configuration)

You mentioned you’re already using a timeout solution, but you can make this work faster with its activity-based timeout feature. Instead of waiting for a fixed duration:

  • Enable "Abort the build if it's stuck"
  • Set the timeout to trigger when there’s no console output for a specific period (e.g., 5 minutes)

This way, as soon as your app stops logging (a common sign of hanging), Jenkins will kill the process immediately instead of waiting out a full timeout window.

3. Health Monitor Plugin

If your application has a built-in health check endpoint (like an HTTP /health API), this plugin can periodically hit that endpoint. If it gets an error response or no response at all, it can trigger a restart script. Even if your app doesn’t have a health endpoint, you can pair this plugin with custom scripts to simulate health checks (e.g., verifying the app is listening on a specific port).

Custom Script + Jenkins Pipeline (For Full Control)

If plugins don’t cover your exact use case, you can roll your own monitoring with scripts integrated into a Jenkins Pipeline. Here’s a quick example for Linux:

#!/bin/bash
APP_NAME="your-test-app"
APP_START_CMD="/path/to/start-your-app.sh"

# Get PID of the app
APP_PID=$(pidof $APP_NAME)

if [ ! -z "$APP_PID" ]; then
  # Check CPU usage (if <5% for 10s, assume it's hung)
  CPU_USAGE=$(ps -p $APP_PID -o %cpu | grep -v CPU | awk '{print $1}')
  if (( $(echo "$CPU_USAGE < 5" | bc -l) )); then
    echo "App is hanging—terminating process $APP_PID"
    kill -9 $APP_PID
    sleep 2
    echo "Restarting app..."
    $APP_START_CMD &
  fi
else
  echo "App not running—starting it..."
  $APP_START_CMD &
fi

Add this script to your Jenkins Pipeline and run it periodically using a cron trigger or as a recurring stage in your job. For Windows, you’d use tasklist and taskkill commands instead.


内容的提问来源于stack exchange,提问作者user2030113

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:38:43