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

fix issues

上级 a1245469
module.exports = {
electronPackagerConfig: {
"name": "ztf2",
"icon": "./ui/favicon.ico"
},
packagerConfig: {
"name": "ztf",
"icon": "./icon/favicon",
extraResource: [
'./bin',
'./ui'
......
import {app, BrowserWindow} from 'electron';
import {getUIServerUrl, startZtfServer} from './services';
import {getUIServerUrl, startZtfServer, killZtfServer} from './services';
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
......@@ -60,9 +60,10 @@ app.on('ready', startApp);
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
// if (process.platform !== 'darwin') {
app.quit();
}
killZtfServer();
// }
});
app.on('activate', () => {
......
......@@ -37,6 +37,7 @@ export function startZtfServer() {
cmd.on('close', (code) => {
console.log(`>> ZTF server closed with code ${code}`);
_ztfServerProcess = null;
cmd.kill()
});
cmd.stdout.on('data', data => {
const dataString = String(data);
......@@ -112,6 +113,10 @@ export function startZtfServer() {
});
}
export function killZtfServer() {
_ztfServerProcess.kill('SIGINT');
}
let _uiServerApp;
export function getUIServerUrl() {
......
package main
import (
"flag"
"github.com/aaronchen2k/deeptest/internal/pkg/lib/log"
"github.com/aaronchen2k/deeptest/internal/server/core/cron"
"github.com/aaronchen2k/deeptest/internal/server/core/dao"
......@@ -16,7 +17,10 @@ import (
// @contact.url https://github.com/easysoft/zentaoatf/issues
// @contact.email 462626@qq.com
func main() {
webServer := web.Init()
port := flag.Int("P", 0, "服务端口")
flag.Parse()
webServer := web.Init(*port)
if webServer == nil {
return
}
......
......@@ -12,56 +12,31 @@ import (
)
func InitLog() {
CONFIG.Zap.Director = filepath.Join(commConsts.WorkDir, CONFIG.Zap.Director)
if !dir.IsExist(CONFIG.Zap.Director) { // 判断是否有Director文件夹
dir.InsureDir(CONFIG.Zap.Director)
}
config := getLogConfig()
zapConfig := getLogConfig()
// print to console
var err error
config.EncoderConfig.EncodeLevel = nil
config.DisableCaller = true
config.EncoderConfig.TimeKey = ""
logUtils.LoggerStandard, err = config.Build()
zapConfig.EncoderConfig.EncodeLevel = nil
zapConfig.DisableCaller = true
zapConfig.EncoderConfig.TimeKey = ""
logUtils.LoggerStandard, err = zapConfig.Build()
if err != nil {
log.Println("init console logger fail " + err.Error())
}
// print to console without detail
config.DisableStacktrace = true
logUtils.LoggerExecConsole, err = config.Build()
zapConfig.DisableStacktrace = true
logUtils.LoggerExecConsole, err = zapConfig.Build()
if err != nil {
log.Println("init exec console logger fail " + err.Error())
}
}
func InitExecLog(projectPath string) {
config := getLogConfig()
commConsts.ExecLogDir = logUtils.GetLogDir(projectPath)
// print to exec log file
config.EncoderConfig.EncodeLevel = nil
config.OutputPaths = []string{filepath.Join(commConsts.ExecLogDir, commConsts.LogText)}
var err error
logUtils.LoggerExecFile, err = config.Build()
if err != nil {
log.Println("init exec file logger fail " + err.Error())
}
config.DisableCaller = true
config.DisableStacktrace = true
config.EncoderConfig.TimeKey = ""
// print to test result file
config.OutputPaths = []string{filepath.Join(commConsts.ExecLogDir, commConsts.ResultText)}
logUtils.LoggerExecResult, err = config.Build()
if err != nil {
log.Println("init exec result logger fail " + err.Error())
}
}
func getLogConfig() (config zap.Config) {
var level zapcore.Level
......@@ -103,13 +78,40 @@ func getLogConfig() (config zap.Config) {
Level: zap.NewAtomicLevelAt(level), // 日志级别
Development: true, // 开发模式,堆栈跟踪
//Encoding: "json", // 输出格式 console 或 json
Encoding: "console", // 输出格式 console 或 json
EncoderConfig: encoderConfig, // 编码器配置
OutputPaths: []string{"stdout"}, // 输出到指定文件 stdout(标准输出,正常颜色) stderr(错误输出,红色)
ErrorOutputPaths: []string{"stderr"},
Encoding: "console", // 输出格式 console 或 json
EncoderConfig: encoderConfig, // 编码器配置
OutputPaths: []string{"stdout", filepath.Join(CONFIG.Zap.Director, "info.log")}, // stdout(标准输出,正常颜色)
ErrorOutputPaths: []string{"stderr", filepath.Join(CONFIG.Zap.Director, "err.log")}, // stderr(错误输出,红色)
//InitialFields: map[string]interface{}{"test_machine": "pc1"}, // 初始化字段
}
config.EncoderConfig.EncodeLevel = zapcore.LowercaseColorLevelEncoder //这里可以指定颜色
return
}
// 执行日志,用于具体的测试执行
func InitExecLog(projectPath string) {
config := getLogConfig()
commConsts.ExecLogDir = logUtils.GetLogDir(projectPath)
// print to exec log file
config.EncoderConfig.EncodeLevel = nil
config.OutputPaths = []string{filepath.Join(commConsts.ExecLogDir, commConsts.LogText)}
var err error
logUtils.LoggerExecFile, err = config.Build()
if err != nil {
log.Println("init exec file logger fail " + err.Error())
}
config.DisableCaller = true
config.DisableStacktrace = true
config.EncoderConfig.TimeKey = ""
// print to test result file
config.OutputPaths = []string{filepath.Join(commConsts.ExecLogDir, commConsts.ResultText)}
logUtils.LoggerExecResult, err = config.Build()
if err != nil {
log.Println("init exec result logger fail " + err.Error())
}
}
......@@ -56,7 +56,7 @@ type WebServer struct {
}
// Init 初始化web服务
func Init() *WebServer {
func Init(port int) *WebServer {
serverConfig.Init()
serverConfig.InitLog()
i118Utils.Init(commConsts.Language, commConsts.AppServer)
......@@ -88,6 +88,9 @@ func Init() *WebServer {
websocketServer := websocket.New(gorilla.Upgrader(gorillaWs.Upgrader{CheckOrigin: func(*http.Request) bool { return true }}), m)
websocketAPI.Get("/", websocket.Handler(websocketServer))
if port != 0 {
serverConfig.CONFIG.System.Addr = fmt.Sprintf(":%d", port)
}
return &WebServer{
app: app,
addr: serverConfig.CONFIG.System.Addr,
......
......@@ -7,9 +7,7 @@
</head>
<body>
<div>
<div>Server状态正常!</div>
<br/>
<div>请继续README.md中的步骤,启动并访问Client服务。</div>
<div>服务启动成功!</div>
</div>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册