|
|
@ -4,7 +4,10 @@ package main |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"flag" |
|
|
|
"flag" |
|
|
|
"runtime" |
|
|
|
slog "log" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"go.uber.org/zap" |
|
|
|
|
|
|
|
"go.uber.org/zap/zapcore" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/shunfei/cronsun" |
|
|
|
"github.com/shunfei/cronsun" |
|
|
|
"github.com/shunfei/cronsun/conf" |
|
|
|
"github.com/shunfei/cronsun/conf" |
|
|
@ -14,14 +17,20 @@ import ( |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
gomax = flag.Int("gomax", |
|
|
|
level = flag.Int("l", -2, "log level, -1:debug, -2:info, -3:warn, -4:error") |
|
|
|
4, "GOMAXPROCS: the max number of operating system threads that can execute") |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
func main() { |
|
|
|
flag.Parse() |
|
|
|
flag.Parse() |
|
|
|
//set cpu usage
|
|
|
|
|
|
|
|
runtime.GOMAXPROCS(*gomax) |
|
|
|
lcf := zap.NewDevelopmentConfig() |
|
|
|
|
|
|
|
lcf.Level.SetLevel(zapcore.Level(*level)) |
|
|
|
|
|
|
|
lcf.Development = false |
|
|
|
|
|
|
|
logger, err := lcf.Build() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
slog.Fatalln("new log err:", err.Error()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
log.SetLogger(logger.Sugar()) |
|
|
|
|
|
|
|
|
|
|
|
if err := cronsun.Init(); err != nil { |
|
|
|
if err := cronsun.Init(); err != nil { |
|
|
|
log.Errorf(err.Error()) |
|
|
|
log.Errorf(err.Error()) |
|
|
|