gin
gin copied to clipboard
Socket file that gin listened are not removed when stopping gin process
Description
When listen to unix socket, socket file are not removed when stopping gin process (use Ctrl + C
). The next time it is executed, the process will report an error: [GIN-debug] [ERROR] listen unix /tmp/testgin.sock: bind: address already in use
How to reproduce
package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "pong",
})
})
file := "/tmp/testgin.sock"
//os.Remove(file)
r.RunUnix(file)
}
Environment
- go version: v1.20.3
- gin version (or commit ref): v1.9.1
- operating system: osx, ubuntu
#2280
The socket should instead be cleaned up at shutdown.
It creates the sock file but does not delete it after Ctrl + C or stop by supervisord. defer os.Remove(file)
not executed.
Maybe I should handle this situation manually?
+1
The socket should instead be cleaned up at shutdown.
It creates the sock file but does not delete it after Ctrl + C or stop by supervisord.
defer os.Remove(file)
not executed.Maybe I should handle this situation manually?
I don't think you should have to, if the service is not running anymore, the socket should disappear imo.
The socket should instead be cleaned up at shutdown.
It creates the sock file but does not delete it after Ctrl + C or stop by supervisord.
defer os.Remove(file)
not executed. Maybe I should handle this situation manually?I don't think you should have to, if the service is not running anymore, the socket should disappear imo.
But it still there 😂