qinglong-go/service/app.go

30 lines
613 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package service
import (
"context"
"github.com/huoxue1/qinglong-go/utils"
log "github.com/sirupsen/logrus"
"os"
"path"
)
func AppInit() {
go runYarn()
}
func runYarn() {
defer func() {
recover()
}()
_, err := os.Stat(path.Join("data", "scripts", "package.json"))
if os.IsNotExist(err) {
return
}
ch := make(chan int, 1)
utils.RunTask(context.WithValue(context.Background(), "cancel", ch), "yarn install", map[string]string{}, func(ctx context.Context) {
log.Infoln("开始执行yarn初始化")
}, func(ctx context.Context) {
log.Infoln("yarn初始化执行完成")
}, os.Stdout)
}