mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-24 17:41:03 +01:00
added part of the system tasks logic
This commit is contained in:
@@ -5,8 +5,11 @@ import (
|
||||
"crawlab/entity"
|
||||
"encoding/json"
|
||||
"github.com/apex/log"
|
||||
"github.com/spf13/viper"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetLangList() []entity.Lang {
|
||||
@@ -123,3 +126,24 @@ func GetPackageJsonDeps(filepath string) (deps []string, err error) {
|
||||
|
||||
return deps, nil
|
||||
}
|
||||
|
||||
// 获取系统脚本列表
|
||||
func GetSystemScripts() (res []string) {
|
||||
scriptsPath := viper.GetString("server.scripts")
|
||||
for _, fInfo := range ListDir(scriptsPath) {
|
||||
if !fInfo.IsDir() && strings.HasSuffix(fInfo.Name(), ".sh") {
|
||||
res = append(res, fInfo.Name())
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func GetSystemScriptPath(scriptName string) string {
|
||||
scriptsPath := viper.GetString("server.scripts")
|
||||
for _, name := range GetSystemScripts() {
|
||||
if name == scriptName {
|
||||
return path.Join(scriptsPath, name)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user