We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
源代码中有一段关键逻辑是 遇到-d=true的参数就强制替换为-d=false(假设该步骤为A), 然后exec.Command执行 经过测试, 步骤A非常关键, 缺少时会有问题. 但步骤A非常神奇, 希望能解释下其具体的作用. 因为ps查看进程时,用本库后台启动的进程始终会带有命令行参数-d=false,这非常具有误导性!
The text was updated successfully, but these errors were encountered:
!!这个daemon不是正确的实现方式,只是一个非常trick的一种做法,不应该在production中使用。
但步骤A非常神奇, 希望能解释下其具体的作用.
if *godaemon { args := os.Args[1:] i := 0 for ; i < len(args); i++ { if args[i] == "-d=true" { args[i] = "-d=false" break } } cmd := exec.Command(os.Args[0], args...) cmd.Start() fmt.Println("[PID]", cmd.Process.Pid) os.Exit(0) }
程序启动时检查到 -d=true,则会以-d=false去启动新的进程,父进程退出,所以新的子进程 -d=false
-d=true
-d=false
Sorry, something went wrong.
No branches or pull requests
源代码中有一段关键逻辑是 遇到-d=true的参数就强制替换为-d=false(假设该步骤为A), 然后exec.Command执行
经过测试, 步骤A非常关键, 缺少时会有问题.
但步骤A非常神奇, 希望能解释下其具体的作用.
因为ps查看进程时,用本库后台启动的进程始终会带有命令行参数-d=false,这非常具有误导性!
The text was updated successfully, but these errors were encountered: