mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-22 08:00:53 +00:00
fix: Initialize the script library when the service starts (#8626)
This commit is contained in:
@@ -195,7 +195,7 @@ func (u *ScriptService) Sync(req dto.OperateByTaskID) error {
|
||||
|
||||
syncTask.Log("start to download data.yaml")
|
||||
dataUrl := fmt.Sprintf("%s/scripts/data.yaml", global.CONF.RemoteURL.ResourceURL)
|
||||
_, dataRes, err := req_helper.HandleRequest(dataUrl, http.MethodGet, constant.TimeOut20s)
|
||||
_, dataRes, err := req_helper.HandleRequestWithProxy(dataUrl, http.MethodGet, constant.TimeOut20s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("load scripts data.yaml from remote failed, err: %v", err)
|
||||
}
|
||||
@@ -213,7 +213,7 @@ func (u *ScriptService) Sync(req dto.OperateByTaskID) error {
|
||||
_ = os.MkdirAll(tmpDir, 0755)
|
||||
}
|
||||
scriptsUrl := fmt.Sprintf("%s/scripts/scripts.tar.gz", global.CONF.RemoteURL.ResourceURL)
|
||||
if err := files.DownloadFile(scriptsUrl, tmpDir+"/scripts.tar.gz"); err != nil {
|
||||
if err := files.DownloadFileWithProxy(scriptsUrl, tmpDir+"/scripts.tar.gz"); err != nil {
|
||||
return fmt.Errorf("download scripts.tar.gz failed, err: %v", err)
|
||||
}
|
||||
syncTask.Log("download successful! now start to decompress...")
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package run
|
||||
|
||||
import (
|
||||
"github.com/1Panel-dev/1Panel/core/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/core/app/service"
|
||||
"github.com/1Panel-dev/1Panel/core/global"
|
||||
)
|
||||
|
||||
func Init() {
|
||||
if err := service.NewIScriptService().Sync(dto.OperateByTaskID{}); err != nil {
|
||||
global.LOG.Errorf("sync scripts from remote failed, err: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,17 @@ import (
|
||||
"crypto/tls"
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"github.com/1Panel-dev/1Panel/core/init/db"
|
||||
"github.com/1Panel-dev/1Panel/core/init/geo"
|
||||
"github.com/1Panel-dev/1Panel/core/init/log"
|
||||
"github.com/1Panel-dev/1Panel/core/init/migration"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/core/init/db"
|
||||
"github.com/1Panel-dev/1Panel/core/init/geo"
|
||||
"github.com/1Panel-dev/1Panel/core/init/log"
|
||||
"github.com/1Panel-dev/1Panel/core/init/migration"
|
||||
"github.com/1Panel-dev/1Panel/core/init/run"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/core/constant"
|
||||
"github.com/1Panel-dev/1Panel/core/global"
|
||||
"github.com/1Panel-dev/1Panel/core/i18n"
|
||||
@@ -42,6 +44,8 @@ func Start() {
|
||||
hook.Init()
|
||||
InitOthers()
|
||||
|
||||
run.Init()
|
||||
|
||||
rootRouter := router.Routers()
|
||||
|
||||
tcpItem := "tcp4"
|
||||
|
||||
Reference in New Issue
Block a user