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

Socket file that gin listened are not removed when stopping gin process #3817

Open
howcrazy opened this issue Jan 3, 2024 · 5 comments
Open

Comments

@howcrazy
Copy link

howcrazy commented Jan 3, 2024

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
@ismdeep
Copy link

ismdeep commented Jan 5, 2024

#2280

@howcrazy
Copy link
Author

howcrazy commented Jan 7, 2024

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?

@openarun
Copy link

openarun commented Feb 6, 2024

+1

@daftaupe
Copy link

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.

@howcrazy
Copy link
Author

howcrazy commented Apr 5, 2024

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 😂

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

4 participants