feat: support powershell

This commit is contained in:
tjq 2021-06-06 10:30:52 +08:00
commit be96d531d1
4 changed files with 50 additions and 5 deletions

View File

@ -55,11 +55,12 @@ public abstract class AbstractScriptProcessor extends CommonBasicProcessor {
}
// 授权
ProcessBuilder chmodPb = new ProcessBuilder("/bin/chmod", "755", scriptPath);
// 等待返回这里不可能导致死锁shell产生大量数据可能导致死锁
chmodPb.start().waitFor();
omsLogger.info("[SYSTEM] chmod 755 authorization complete, ready to start execution~");
if ( !SystemUtils.IS_OS_WINDOWS) {
ProcessBuilder chmodPb = new ProcessBuilder("/bin/chmod", "755", scriptPath);
// 等待返回这里不可能导致死锁shell产生大量数据可能导致死锁
chmodPb.start().waitFor();
omsLogger.info("[SYSTEM] chmod 755 authorization complete, ready to start execution~");
}
// 2. 执行目标脚本
ProcessBuilder pb = new ProcessBuilder(getRunCommand(), scriptPath);
Process process = pb.start();

View File

@ -0,0 +1,20 @@
package tech.powerjob.official.processors.impl.script;
/**
* python processor
*
* @author fddc
* @since 2021/5/14
*/
public class PowerShellProcessor extends AbstractScriptProcessor {
@Override
protected String getScriptName(Long instanceId) {
return String.format("powershell_%d.bat", instanceId);
}
@Override
protected String getRunCommand() {
return "powershell.exe";
}
}

View File

@ -0,0 +1,20 @@
package tech.powerjob.official.processors.impl.script;
/**
* python processor
*
* @author fddc
* @since 2021/5/14
*/
public class PowerShellProcessor extends AbstractScriptProcessor {
@Override
protected String getScriptName(Long instanceId) {
return String.format("powershell_%d.bat", instanceId);
}
@Override
protected String getRunCommand() {
return "powershell.exe";
}
}

View File

@ -36,6 +36,9 @@ public class MainApplication implements Runnable {
@Option(names = {"-l", "--length"}, description = "ProcessResult#msg max length")
private int length = 1024;
@Option(names = {"-t", "--tag"}, description = "worker-agent's tag")
private String tag;
public static void main(String[] args) {
CommandLine commandLine = new CommandLine(new MainApplication());
commandLine.execute(args);
@ -52,6 +55,7 @@ public class MainApplication implements Runnable {
cfg.setServerAddress(Splitter.on(",").splitToList(server));
cfg.setStoreStrategy(StoreStrategy.MEMORY.name().equals(storeStrategy) ? StoreStrategy.MEMORY : StoreStrategy.DISK);
cfg.setMaxResultLength(length);
cfg.setTag(tag);
PowerJobWorker worker = new PowerJobWorker();
worker.setConfig(cfg);