Avoid opening log output before start &

Replace tracing logs with task monitor
This commit is contained in:
世界
2023-12-04 11:47:25 +08:00
parent f998ccecde
commit abd4d8b367
14 changed files with 231 additions and 266 deletions

View File

@@ -13,6 +13,7 @@ import (
"time"
"github.com/sagernet/sing-box"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing-box/option"
E "github.com/sagernet/sing/common/exceptions"
@@ -193,7 +194,7 @@ func run() error {
}
func closeMonitor(ctx context.Context) {
time.Sleep(3 * time.Second)
time.Sleep(C.DefaultStopFatalTimeout)
select {
case <-ctx.Done():
return

View File

@@ -1,6 +1,7 @@
package main
import (
"context"
"os"
"time"
@@ -37,7 +38,7 @@ func main() {
func preRun(cmd *cobra.Command, args []string) {
if disableColor {
log.SetStdLogger(log.NewFactory(log.Formatter{BaseTime: time.Now(), DisableColors: true}, os.Stderr, nil).Logger())
log.SetStdLogger(log.NewDefaultFactory(context.Background(), log.Formatter{BaseTime: time.Now(), DisableColors: true}, os.Stderr, "", nil, false).Logger())
}
if workingDir != "" {
_, err := os.Stat(workingDir)