提交 18ca3751 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

fix package issue issues

上级 271fcfe0
Version = 2.2
Version = 2.3
Language = zh
VERSION=3.0
VERSION=2.3
PROJECT=zd
QINIU_DIR=/Users/aaron/work/zentao/qiniu/
QINIU_DIST_DIR=${QINIU_DIR}${PROJECT}/${VERSION}/
......
......@@ -8,7 +8,11 @@ import (
consts "github.com/easysoft/zendata/internal/pkg/const"
"github.com/easysoft/zendata/internal/pkg/gen"
"github.com/easysoft/zendata/internal/pkg/helper"
serverConfig "github.com/easysoft/zendata/internal/server/config"
"github.com/easysoft/zendata/internal/server/core/web"
serverConst "github.com/easysoft/zendata/internal/server/utils/const"
fileUtils "github.com/easysoft/zendata/pkg/utils/file"
i118Utils "github.com/easysoft/zendata/pkg/utils/i118"
logUtils "github.com/easysoft/zendata/pkg/utils/log"
"github.com/easysoft/zendata/pkg/utils/vari"
"github.com/fatih/color"
......@@ -43,6 +47,9 @@ var (
help bool
set bool
isStartServer bool
uuid = ""
flagSet *flag.FlagSet
)
......@@ -117,8 +124,8 @@ func main() {
flagSet.StringVar(&vari.GlobalVars.Table, "t", "", "")
flagSet.StringVar(&vari.GlobalVars.Table, "table", "", "")
flagSet.StringVar(&vari.GlobalVars.DBDsn, "dsn", "", "")
flagSet.StringVar(&vari.GlobalVars.DBType, "s", "mysql", "")
flagSet.StringVar(&vari.GlobalVars.DBType, "server", "mysql", "")
flagSet.StringVar(&vari.GlobalVars.DBType, "db", "db", "")
flagSet.StringVar(&vari.GlobalVars.DBType, "server", "mysql", "") // TODO: will remove
flagSet.BoolVar(&vari.GlobalVars.DBClear, "clear", false, "")
flagSet.StringVar(&vari.ProtoCls, "cls", "", "")
......@@ -128,6 +135,22 @@ func main() {
flagSet.BoolVar(&help, "h", false, "")
flagSet.BoolVar(&help, "help", false, "")
// for server
flagSet.BoolVar(&isStartServer, "s", false, "启动服务")
flagSet.StringVar(&uuid, "uuid", "", "区分服务进程的唯一ID")
flagSet.IntVar(&vari.DataServicePort, "p", 8848, "")
flagSet.IntVar(&vari.DataServicePort, "port", 0, "")
flagSet.Parse(os.Args[1:])
if isStartServer {
startServer()
} else {
execCommand()
}
}
func execCommand() {
if len(os.Args) == 1 {
os.Args = append(os.Args, "-help")
}
......@@ -150,6 +173,29 @@ func main() {
}
}
func startServer() {
configUtils.InitConfig("")
vari.DB, _ = serverConfig.NewGormDB()
vari.AgentLogDir = vari.ZdPath + serverConst.AgentLogDir + consts.PthSep
err := fileUtils.MkDirIfNeeded(vari.AgentLogDir)
if err != nil {
logUtils.PrintToWithColor(i118Utils.I118Prt.Sprintf("perm_deny", vari.AgentLogDir), color.FgRed)
os.Exit(1)
}
if vari.DataServicePort == 0 {
vari.DataServicePort = consts.DefaultDataServicePort
}
webServer := web.Init()
if webServer == nil {
return
}
webServer.Run()
}
func opts(files []string) {
if exportFields != "" {
vari.GlobalVars.ExportFields = strings.Split(exportFields, ",")
......
......@@ -2,12 +2,8 @@ package main
import (
"flag"
"fmt"
zd "github.com/easysoft/zendata"
"github.com/easysoft/zendata/internal/agent"
configUtils "github.com/easysoft/zendata/internal/pkg/config"
consts "github.com/easysoft/zendata/internal/pkg/const"
"github.com/easysoft/zendata/internal/server"
serverConfig "github.com/easysoft/zendata/internal/server/config"
"github.com/easysoft/zendata/internal/server/core/web"
serverConst "github.com/easysoft/zendata/internal/server/utils/const"
......@@ -17,10 +13,8 @@ import (
logUtils "github.com/easysoft/zendata/pkg/utils/log"
"github.com/easysoft/zendata/pkg/utils/vari"
"github.com/fatih/color"
"net/http"
"os"
"os/signal"
"strconv"
"syscall"
)
......@@ -65,33 +59,6 @@ func main() {
vari.DataServicePort = consts.DefaultDataServicePort
}
//go func() {
// startDataServer()
//}()
startServer()
}
func startDataServer() {
port := strconv.Itoa(vari.DataServicePort)
logUtils.PrintToWithColor(i118Utils.I118Prt.Sprintf("start_server",
vari.Ip, port, vari.Ip, port, vari.Ip, port), color.FgCyan)
config := serverConfig.NewConfig()
server, err := server.InitServer(config)
if err != nil {
logUtils.PrintToWithColor(i118Utils.I118Prt.Sprintf("start_server_fail", port), color.FgRed)
}
httpServer := &http.Server{
Addr: fmt.Sprintf(":%d", server.Config.ServerPort),
Handler: dataHandler(server),
}
httpServer.ListenAndServe()
}
func startServer() {
webServer := web.Init()
if webServer == nil {
return
......@@ -100,20 +67,6 @@ func startServer() {
webServer.Run()
}
func dataHandler(server *server.Server) http.Handler {
mux := http.NewServeMux()
uiFs, err := zd.GetUiFileSys()
if err != nil {
panic(err)
}
mux.Handle("/", http.FileServer(http.FS(uiFs)))
mux.HandleFunc("/data", agent.DataHandler)
return mux
}
func init() {
cleanup()
}
......
......@@ -68,10 +68,9 @@ var (
RightBrackets rune = ')'
Backtick rune = '`'
DefaultDataServicePort = 8848
DefaultAdminServicePort = 8085
DefaultRoot = "./"
DefaultNumber = 10
DefaultDataServicePort = 8848
DefaultRoot = "./"
DefaultNumber = 10
ResDirData = "data"
ResDirYaml = "yaml"
......
......@@ -5,13 +5,11 @@ import (
)
type Config struct {
ServerIP string
ServerPort int
}
func NewConfig() *Config {
return &Config{
ServerIP: vari.Ip,
ServerPort: vari.DataServicePort,
}
}
......@@ -4,7 +4,6 @@ import (
stdContext "context"
"fmt"
zd "github.com/easysoft/zendata"
consts "github.com/easysoft/zendata/internal/pkg/const"
"github.com/easysoft/zendata/internal/server"
"github.com/easysoft/zendata/internal/server/core/module"
logUtils "github.com/easysoft/zendata/pkg/utils/log"
......@@ -51,7 +50,7 @@ func Init() *WebServer {
mvc.New(app)
addr := fmt.Sprintf(":%d", consts.DefaultAdminServicePort)
addr := fmt.Sprintf(":%d", vari.DataServicePort)
webServer := &WebServer{
app: app,
......
......@@ -78,7 +78,6 @@ var (
ProtoCls string
JsonResp string = "[]"
Ip string
DataServicePort int
ResLoading = false
......
......@@ -6,7 +6,7 @@ Parameters:
-c --config The current config file for data format, and it can override the config in the default file.
-o --output The file name of the data generated. You can specify the output format by the extension name.
For example json, xml, sql, csv and xlsx. The text data in the original format is output by default.
Note: For SQL files, you can use --server to specify a specific database type in Mysql\Oracle\SqlServer.
Note: For SQL files, you can use --db to specify a specific database type in Mysql,Oracle,SqlServer.
-n --lines The number of lines of data to be generated. The default is 10.
-F --field This parameter can be used to specify the fields, separated by commas. The default is all fields.
......
......@@ -5,7 +5,7 @@ ZenData是一款通用的数据生成工具,您可以使用yaml文件来定义
-d --default 默认的数据格式配置文件。
-c --config 当前场景的数据格式配置文件,可以覆盖默认文件里面的设置。
-o --output 生成的数据的文件名。可通过扩展名指定输出json|xml|sql|csv|xlsx格式的数据。默认输出原始格式的文本数据。
注意:对于 SQL 文件,您可以使用 --server 指定Mysql\Oracle\SqlServer中具体的数据库类型。
注意:对于 SQL 文件,您可以使用 --db 指定Mysql、Oracle、SqlServer中具体的数据库类型。
-n --lines 要生成的记录条数,默认为10条。
-F --field 可通过该参数指定要输出的字段列表,用逗号分隔。 默认是所有的字段。
......
......@@ -17,12 +17,14 @@ function initRequest(remoteUrl) {
function getUrl() {
let url = ''
if (process.env.NODE_ENV === "development") {
url = 'http://127.0.0.1:8085/api/v1'
url = 'http://127.0.0.1:8848/api/v1'
console.log('dev env, url is ' + url)
} else {
const location = unescape(window.location.href);
url = location.split('#')[0].split('index.html')[0];
console.log('prod env, url is ' + url)
}
return url
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册