mirror of
https://github.com/PowerJob/PowerJob.git
synced 2025-07-17 00:00:04 +08:00
fix: Judge if OS is Windows and whether to run shell scripts
This commit is contained in:
commit
83f6cf50a7
27
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
27
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
## What is the purpose of the change
|
||||||
|
|
||||||
|
For example: Making PowerJob better
|
||||||
|
|
||||||
|
## Brief changelog
|
||||||
|
|
||||||
|
It is best to associate an existing issue
|
||||||
|
|
||||||
|
## Verifying this change
|
||||||
|
|
||||||
|
Do I need to test?
|
||||||
|
Has testing been completed?
|
||||||
|
Test method?
|
||||||
|
|
||||||
|
Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 3 checklist before request the community to review your PR`.
|
||||||
|
|
||||||
|
- [x] Make sure there is a [Github issue](https://github.com/PowerJob/PowerJob/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
|
||||||
|
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
|
||||||
|
- [x] Follow the git commit specification
|
||||||
|
* feat: xxx -> The feat type is used to identify production changes related to new backward-compatible abilities or functionality.
|
||||||
|
* perf: xxx -> The perf type is used to identify production changes related to backward-compatible performance improvements.
|
||||||
|
* fix: xxx -> The fix type is used to identify production changes related to backward-compatible bug fixes.
|
||||||
|
* docs: xxx -> The docs type is used to identify documentation changes related to the project - whether intended externally for the end users (in case of a library) or internally for the developers.
|
||||||
|
* test: xxx -> The test type is used to identify development changes related to tests - such as refactoring existing tests or adding new tests.
|
||||||
|
* refactor: xxx -> The refactor type is used to identify development changes related to modifying the codebase, which neither adds a feature nor fixes a bug - such as removing redundant code, simplifying the code, renaming variables, etc.
|
||||||
|
|
||||||
|
|
@ -42,13 +42,17 @@ Refer to [PowerJob Introduction](https://www.yuque.com/powerjob/en/introduce) fo
|
|||||||
|
|
||||||
### Online trial
|
### Online trial
|
||||||
- Address: [try.powerjob.tech](http://try.powerjob.tech/#/welcome?appName=powerjob-agent-test&password=123)
|
- Address: [try.powerjob.tech](http://try.powerjob.tech/#/welcome?appName=powerjob-agent-test&password=123)
|
||||||
- Recommended to read the documentation first: [here](https://www.yuque.com/powerjob/en/trial)
|
- Recommend reading the documentation first: [here](https://www.yuque.com/powerjob/en/trial)
|
||||||
|
|
||||||
# Documents
|
# Documents
|
||||||
**[Docs](https://www.yuque.com/powerjob/en/introduce)**
|
**[Docs](https://www.yuque.com/powerjob/en/introduce)**
|
||||||
|
|
||||||
**[中文文档](https://www.yuque.com/powerjob/guidence/intro)**
|
**[中文文档](https://www.yuque.com/powerjob/guidence/intro)**
|
||||||
|
|
||||||
|
## Stargazers over time
|
||||||
|
|
||||||
|
[](https://starchart.cc/PowerJob/PowerJob)
|
||||||
|
|
||||||
# Known Users
|
# Known Users
|
||||||
[Click to register as PowerJob user!](https://github.com/PowerJob/PowerJob/issues/6)
|
[Click to register as PowerJob user!](https://github.com/PowerJob/PowerJob/issues/6)
|
||||||
ღ( ´・ᴗ・\` )ღ Many thanks to the following registered users. ღ( ´・ᴗ・\` )ღ
|
ღ( ´・ᴗ・\` )ღ Many thanks to the following registered users. ღ( ´・ᴗ・\` )ღ
|
||||||
@ -62,7 +66,7 @@ PowerJob is released under Apache License 2.0. Please refer to [License](./LICEN
|
|||||||
|
|
||||||
# Others
|
# Others
|
||||||
|
|
||||||
- Any developer interested in getting more involved in PowerJob may join our [Gitter Community](https://gitter.im/PowerJob/community) and make [contributions](https://github.com/PowerJob/PowerJob/pulls)!
|
- Any developer interested in getting more involved in PowerJob may join our [Reddit](https://www.reddit.com/r/PowerJob) or [Gitter](https://gitter.im/PowerJob/community) community and make [contributions](https://github.com/PowerJob/PowerJob/pulls)!
|
||||||
|
|
||||||
- Reach out to me through email **tengjiqi@gmail.com**. Any issues or questions are welcomed on [Issues](https://github.com/PowerJob/PowerJob/issues).
|
- Reach out to me through email **tengjiqi@gmail.com**. Any issues or questions are welcomed on [Issues](https://github.com/PowerJob/PowerJob/issues).
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@ 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;
|
||||||
@ -44,6 +46,9 @@ 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");
|
||||||
@ -70,11 +75,18 @@ public abstract class ScriptProcessor implements BasicProcessor {
|
|||||||
OmsLogger omsLogger = context.getOmsLogger();
|
OmsLogger omsLogger = context.getOmsLogger();
|
||||||
|
|
||||||
omsLogger.info("SYSTEM===> ScriptProcessor start to process");
|
omsLogger.info("SYSTEM===> ScriptProcessor start to process");
|
||||||
|
|
||||||
// 1. 授权
|
if (SystemUtils.IS_OS_WINDOWS) {
|
||||||
ProcessBuilder chmodPb = new ProcessBuilder("/bin/chmod", "755", scriptPath);
|
if (StringUtils.equals(fetchRunCommand(), "/bin/bash")) {
|
||||||
// 等待返回,这里不可能导致死锁(shell产生大量数据可能导致死锁)
|
omsLogger.warn("Current OS is {} where shell scripts cannot run.", SystemUtils.OS_NAME);
|
||||||
chmodPb.start().waitFor();
|
return new ProcessResult(false, "Shell scripts cannot run on Windows");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 1. 授权
|
||||||
|
ProcessBuilder chmodPb = new ProcessBuilder("/bin/chmod", "755", scriptPath);
|
||||||
|
// 等待返回,这里不可能导致死锁(shell产生大量数据可能导致死锁)
|
||||||
|
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