|
@@ -1,10 +1,10 @@
|
|
|
const file = require("./utils/file");
|
|
|
const {getRustConfig} = require("./config");
|
|
|
-const {spawn, exec, fork, execSync} = require("child_process");
|
|
|
+const {spawn, exec, execSync} = require("child_process");
|
|
|
const {logger} = require("./utils/logger");
|
|
|
const http = require("./utils/http");
|
|
|
-const e = require("express");
|
|
|
-const {is, tr} = require("date-fns/locale");
|
|
|
+
|
|
|
+
|
|
|
|
|
|
* web
|
|
|
* **** */
|
|
@@ -106,7 +106,22 @@ async function run(param) {
|
|
|
|
|
|
appPath = config.filePath + "/" + app.id + "/" + strategyName + "/" + programName
|
|
|
|
|
|
- file.checkPathSync(appPath);
|
|
|
+ let is_exist = file.checkFilePath(appPath)
|
|
|
+
|
|
|
+ if (!is_exist){
|
|
|
+
|
|
|
+ let clear_command = `sudo find ` + config.filePath + "/" + app.id + ` -mindepth 1 -delete`
|
|
|
+ exec(clear_command, (error, stdout, stderr) => {
|
|
|
+ if (error) {
|
|
|
+ logger.error(`清理不用的策略文件:清理失败: ${error}`);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ await delay(1000);
|
|
|
+
|
|
|
+ file.mkdir(appPath);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
*** 第三步:rust 启动程序检查(下载更新)
|
|
@@ -117,11 +132,14 @@ async function run(param) {
|
|
|
var scheduleConfig = 0
|
|
|
|
|
|
var destination = appPath + "/" + exeName
|
|
|
- if (!file.checkFilePath(destination)) {
|
|
|
+
|
|
|
+ let is_program_exist = file.checkFilePath(destination);
|
|
|
+ if (!is_program_exist) {
|
|
|
app.threadStatus = RobotStatus.DOWNLOADING
|
|
|
robotStatus(app)
|
|
|
isDow = true
|
|
|
var dowHeaders = {...config.headers};
|
|
|
+
|
|
|
if (platform === 'win32') {
|
|
|
downloadFileWithPowerShell(
|
|
|
config.baseUrl + config.dowAppURL + '/?path=' + appName,
|
|
@@ -248,7 +266,7 @@ async function run(param) {
|
|
|
|
|
|
const exePath = appPath + "/" + exeName
|
|
|
const configPath = appPath + "/" + configName
|
|
|
- logger.info(`文件地址:${exePath}-----${configPath}`);
|
|
|
+
|
|
|
const command = exePath
|
|
|
const args = ['--config=' + configPath, '--port=' + app.port]
|
|
|
app.childProcess = spawn(command, args)
|
|
@@ -543,13 +561,25 @@ function robotAmount(app) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-function delRobot(app) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+function delRobotLog(app) {
|
|
|
+
|
|
|
+ let deleteLogCommand = `sudo find logs` + app.port + ` -type f -mtime +3 -exec rm {} \\;`;
|
|
|
+ exec(deleteLogCommand, (error, stdout, stderr) => {
|
|
|
+ if (error) {
|
|
|
+ logger.error(`清理机器人日志命令执行失败~: ${deleteLogCommand} 错误:${error}`);
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function delNodeLog() {
|
|
|
+
|
|
|
+ let deleteLogCommand = `sudo find logs/node -type f -mtime +3 -exec rm {} \\;`;
|
|
|
+ exec(deleteLogCommand, (error, stdout, stderr) => {
|
|
|
+ if (error) {
|
|
|
+ logger.error(`清理node日志命令执行失败~:错误:${error}`);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
|
|
@@ -559,7 +589,8 @@ module.exports = {
|
|
|
run,
|
|
|
closeApp,
|
|
|
restartApp,
|
|
|
- delRobot,
|
|
|
+ delRobotLog,
|
|
|
+ delNodeLog,
|
|
|
robotStatus,
|
|
|
robotAmount,
|
|
|
closeAppAll,
|