mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
fix: rollback ScriptProcessor to fix bug #222
This commit is contained in:
parent
3d1c907104
commit
ec9519a6b2
@ -8,8 +8,6 @@ import com.github.kfcfans.powerjob.worker.log.OmsLogger;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.commons.lang3.SystemUtils;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -46,9 +44,6 @@ public abstract class ScriptProcessor implements BasicProcessor {
|
|||||||
|
|
||||||
File dir = new File(script.getParent());
|
File dir = new File(script.getParent());
|
||||||
boolean success = dir.mkdirs();
|
boolean success = dir.mkdirs();
|
||||||
if (!success) {
|
|
||||||
throw new RuntimeException("create script folder failed.");
|
|
||||||
}
|
|
||||||
success = script.createNewFile();
|
success = script.createNewFile();
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw new RuntimeException("create script file failed");
|
throw new RuntimeException("create script file failed");
|
||||||
@ -76,17 +71,10 @@ public abstract class ScriptProcessor implements BasicProcessor {
|
|||||||
|
|
||||||
omsLogger.info("SYSTEM===> ScriptProcessor start to process");
|
omsLogger.info("SYSTEM===> ScriptProcessor start to process");
|
||||||
|
|
||||||
if (SystemUtils.IS_OS_WINDOWS) {
|
|
||||||
if (StringUtils.equals(fetchRunCommand(), "/bin/bash")) {
|
|
||||||
omsLogger.warn("Current OS is {} where shell scripts cannot run.", SystemUtils.OS_NAME);
|
|
||||||
return new ProcessResult(false, "Shell scripts cannot run on Windows");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 1. 授权
|
// 1. 授权
|
||||||
ProcessBuilder chmodPb = new ProcessBuilder("/bin/chmod", "755", scriptPath);
|
ProcessBuilder chmodPb = new ProcessBuilder("/bin/chmod", "755", scriptPath);
|
||||||
// 等待返回,这里不可能导致死锁(shell产生大量数据可能导致死锁)
|
// 等待返回,这里不可能导致死锁(shell产生大量数据可能导致死锁)
|
||||||
chmodPb.start().waitFor();
|
chmodPb.start().waitFor();
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 执行目标脚本
|
// 2. 执行目标脚本
|
||||||
ProcessBuilder pb = new ProcessBuilder(fetchRunCommand(), scriptPath);
|
ProcessBuilder pb = new ProcessBuilder(fetchRunCommand(), scriptPath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user