Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

About unix bug: 'bind: address already in use. ' #139

Open
zmaplex opened this issue Sep 19, 2022 · 0 comments
Open

About unix bug: 'bind: address already in use. ' #139

zmaplex opened this issue Sep 19, 2022 · 0 comments

Comments

@zmaplex
Copy link

zmaplex commented Sep 19, 2022

First start

-# ./webdav -c config.yaml
2022-09-18T22:18:08.522-0400    info    Listening       {"address": "/run/ui-ssh-webdav.socket"}

Second launch after ending the process with ctrl + c command

-# ./webdav -c config.yaml
2022/09/18 22:19:34 listen unix /run/ui-ssh-webdav.socket: bind: address already in use

Must be executerm -rf /run/ui-ssh-webdav.socket command to resolve it.

config.yaml

address: unix:/run/ui-ssh-webdav.socket
auth: true
....

Hope the following information can help you

https://stackoverflow.com/questions/16681944/how-to-reliably-unlink-a-unix-domain-socket-in-go-programming-language

// Create the socket to listen on:
l, err := net.Listen(socketType, socketAddr)
if err != nil {
    log.Fatal(err)
    return
}

// Unix sockets must be unlink()ed before being reused again.

// Handle common process-killing signals so we can gracefully shut down:
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, os.Interrupt, os.Kill, syscall.SIGTERM)
go func(c chan os.Signal) {
    // Wait for a SIGINT or SIGKILL:
    sig := <-c
    log.Printf("Caught signal %s: shutting down.", sig)
    // Stop listening (and unlink the socket if unix type):
    l.Close()
    // And we're done:
    os.Exit(0)
}(sigc)

// Start the HTTP server:
log.Fatal(http.Serve(l, http.HandlerFunc(indexHtml)))
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant