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
env: Linux l-qfy0.dba.dev.cn0 3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
go version go1.17 linux/amd64
test.go
import ( "context" "flag" "fmt" "os/exec" "strconv" "syscall" "github.com/fvbock/endless" "github.com/gin-gonic/gin" ) var ctx context.Context var cancel context.CancelFunc var reload bool var port = flag.Int("port", 8080, "") func main() { flag.Parse() ListenHTTP(setReload) } func setReload() { reload = true } func ListenHTTP(reloadFunc func()) error { var handler = gin.Default() handler.GET("/", startDaemon()) handler.GET("/hello", hello()) ctx, cancel = context.WithCancel(context.Background()) defer cancel() s := endless.NewServer(":"+strconv.Itoa(*port), handler) go func() { select { case <-ctx.Done(): } if s != nil { if err := s.Shutdown(ctx); err != nil { fmt.Println(err) } } }() s.SignalHooks[endless.PRE_SIGNAL][syscall.SIGHUP] = append( s.SignalHooks[endless.PRE_SIGNAL][syscall.SIGHUP], reloadFunc) if err := s.ListenAndServe(); err != nil { return err } return nil } func hello() gin.HandlerFunc { return func(c *gin.Context) { fmt.Println("hello ", *port) } } func startDaemon() gin.HandlerFunc { return func(c *gin.Context) { start(c) } } func start(c *gin.Context) (err error) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() cmd := exec.CommandContext(ctx, "sh", []string{"start.sh"}...) err = cmd.Run() if err != nil { fmt.Println(err) return } return }
start.sh
nohup /home/qfy/tmp/test --port=8081 > /dev/null 2>&1 &
basedir:/root/tmp
steps:
4.then send http requst,but 8081 is not listening
Is that a bug need to fix ? And how can I resolve it.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
env:
Linux l-qfy0.dba.dev.cn0 3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
go version go1.17 linux/amd64
test.go
start.sh
basedir:/root/tmp
steps:
4.then send http requst,but 8081 is not listening

Is that a bug need to fix ?
And how can I resolve it.
The text was updated successfully, but these errors were encountered: