Delete socket file on server shutdown

This commit is contained in:
Matt Baer 2022-12-26 13:20:28 -05:00
parent f84b4b0f74
commit a0f1e1821f
1 changed files with 10 additions and 0 deletions

10
app.go
View File

@ -845,6 +845,16 @@ func connectToDatabase(app *App) {
func shutdown(app *App) {
log.Info("Closing database connection...")
app.db.Close()
if strings.HasPrefix(app.cfg.Server.Bind, "/") {
// Clean up socket
log.Info("Removing socket file...")
err := os.Remove(app.cfg.Server.Bind)
if err != nil {
log.Error("Unable to remove socket: %s", err)
os.Exit(1)
}
log.Info("Success.")
}
}
// CreateUser creates a new admin or normal user from the given credentials.