GDAEMONEXPIRED cicd system_error ai_generated partial

org.gradle.launcher.daemon.server.DaemonExpirationPeriodicCheck:守护进程将在运行 3 小时后于构建结束时停止

org.gradle.launcher.daemon.server.DaemonExpirationPeriodicCheck: Daemon will be stopped at the end of the build after running for 3 hours

ID: cicd/gradle-daemon-stopped

其他格式: JSON · Markdown 中文 · English
78%修复率
83%置信度
1证据数
2024-01-10首次发现

版本兼容性

版本状态引入弃用备注
Gradle 8.5 active
Gradle 8.7 active
Gradle 7.6.3 active

根因分析

Gradle 的守护进程由于在 gradle.properties 中配置的空闲超时或最大年龄限制而自动终止,导致后续构建重启守护进程并丢失缓存状态。

English

Gradle's daemon process is automatically terminated due to idle timeout or maximum age limits configured in gradle.properties, causing subsequent builds to restart the daemon and lose cached state.

generic

官方文档

https://docs.gradle.org/current/userguide/gradle_daemon.html

解决方案

  1. Increase daemon idle timeout in gradle.properties: `org.gradle.daemon.idletimeout=7200000` (2 hours)
  2. Set daemon max age to a higher value: `org.gradle.daemon.registry.base.expiration=86400000` (24 hours) in gradle.properties
  3. Use the `--no-daemon` flag for short-lived CI builds to avoid daemon overhead, and rely on build cache instead: `gradle build --no-daemon --build-cache`

无效尝试

常见但无效的做法:

  1. Set org.gradle.daemon=false in gradle.properties to disable daemon entirely 75% 失败

    Disabling the daemon removes the caching benefit entirely, making builds significantly slower in CI environments.

  2. Increase the daemon heap size with -Xmx to prevent memory-related stops 90% 失败

    Heap size does not affect the idle timeout or age-based expiration; the daemon will still stop after the configured duration.

  3. Restart the CI worker node to clear the daemon lock file 60% 失败

    Restarting the node resets the daemon but does not address the underlying configuration causing the expiration.