davidzollo commented on code in PR #17005:
URL:
https://github.com/apache/dolphinscheduler/pull/17005#discussion_r1959792553
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java:
##########
@@ -85,31 +85,105 @@ private ProcessUtils() {
private static final Pattern LINUXPATTERN =
Pattern.compile("\\((\\d+)\\)");
/**
- * kill tasks according to different task types.
+ * Terminate the task process, support multi-level signal processing and
fallback strategy
+ * @param request Task execution context
+ * @return Whether the process was successfully terminated
*/
- @Deprecated
public static boolean kill(@NonNull TaskExecutionContext request) {
try {
- log.info("Begin kill task instance, processId: {}",
request.getProcessId());
+ log.info("Begin killing task instance, processId: {}",
request.getProcessId());
int processId = request.getProcessId();
if (processId == 0) {
- log.error("Task instance kill failed, processId is not exist");
+ log.error("Task instance kill failed, processId is not
available");
return false;
}
- String cmd = String.format("kill -9 %s", getPidsStr(processId));
- cmd = OSUtils.getSudoCmd(request.getTenantCode(), cmd);
- log.info("process id:{}, cmd:{}", processId, cmd);
+ // Get all child processes
+ String pids = getPidsStr(processId);
+ String[] pidArray = pids.split("\\s+");
+ if (pidArray.length == 0) {
+ log.warn("No valid PIDs found for process: {}", processId);
+ return true;
+ }
+
+ // 1. Try to terminate gracefully (SIGINT)
+ boolean gracefulKillSuccess = sendKillSignal("SIGINT", pids,
request.getTenantCode(), 2000);
Review Comment:
I have removed this wait time
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]