Skip to content
New issue

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

Any way to graceful restart the gin http and https servers like nginx for production? #3609

Open
snowdream opened this issue May 21, 2023 · 2 comments

Comments

@snowdream
Copy link

snowdream commented May 21, 2023

  • With issues:
    • Use the search tool before opening a new issue.
    • Please provide source code and commit sha if you found a bug.
    • Review existing issues and provide feedback or react to them.

Description

For Example, I edit nginx config file ,and exec ‘nginx -s reload’.
I can graceful restart the nginx.
Any way to graceful restart the gin http and https servers like nginx for production?

How to reproduce

package main

import (
	"github.com/gin-gonic/gin"
)

func main() {
	g := gin.Default()
	g.GET("/hello/:name", func(c *gin.Context) {
		c.String(200, "Hello %s", c.Param("name"))
	})
	g.Run(":9000")
}

Expectations

$ curl http://localhost:8201/hello/world
Hello world

Actual result

$ curl -i http://localhost:8201/hello/world
<YOUR RESULT>

Environment

  • go version:
  • gin version (or commit ref):
  • operating system:
@snowdream snowdream changed the title Any way to graceful restart the gin http and https server like nginx for production? Any way to graceful restart the gin http and https servers like nginx for production? May 21, 2023
@snowdream
Copy link
Author

https://github.com/cosmtrek/air

Note: This tool has nothing to do with hot-deploy for production.

@cedric-appdirect
Copy link

I have made a PR gin-contrib/graceful#2 that add support for Gin. You should be able to do what you want by monitoring the file you want on your system, then use Stop(), modify your service setup as you want and then call Start() on it again.

I haven't received any feedback on my PR yet, so would appreciate anyone looking at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants