You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by "ruanwenjun (via GitHub)" <gi...@apache.org> on 2023/03/09 03:05:52 UTC

[GitHub] [dolphinscheduler] ruanwenjun commented on a diff in pull request #13689: Clearer task runnable.

ruanwenjun commented on code in PR #13689:
URL: https://github.com/apache/dolphinscheduler/pull/13689#discussion_r1130347103


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java:
##########
@@ -278,53 +276,18 @@ public String getVarPool() {
         return varPool.toString();
     }
 
-    /**
-     * cancel application
-     *
-     * @throws Exception exception
-     */
-    public void cancelApplication() throws Exception {
+    public void cancelApplication() {
         if (process == null) {
             return;
         }
 
-        int processId = getProcessId(process);
-        logger.info("Begin to kill process process, pid is : {}", processId);
-        // kill , waiting for completion
-        boolean alive = softKill(processId);
-
-        if (alive) {
-            String cmd = String.format("kill -9 %s", getPidsStr(processId));
-            cmd = OSUtils.getSudoCmd(taskRequest.getTenantCode(), cmd);
-            OSUtils.exeCmd(cmd);
-            logger.info("Success kill task: {}, pid: {}, cmd: {}", taskRequest.getTaskAppId(), processId, cmd);
-        } else {
-            logger.info("The process: {} is not alive, no need to kill", processId);
+        // soft kill
+        logger.info("Begin to kill process process, pid is : {}", taskRequest.getProcessId());
+        process.destroy();
+        if (process.isAlive()) {
+            process.destroyForcibly();

Review Comment:
   Done, thanks for your suggestion.



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org