Skip to content

Commit

Permalink
recreate the control socket after a crash; fixes bblfsh#286
Browse files Browse the repository at this point in the history
Signed-off-by: Denys Smirnov <[email protected]>
  • Loading branch information
Denys Smirnov committed May 6, 2019
1 parent 01eba1f commit 5787893
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/bblfshd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ func listenUser(d *daemon.Daemon) {

func listenControl(d *daemon.Daemon) {
var err error
if *ctl.network == "unix" {
// Remove returns an error if file does not exists
// if it returns nil, we know the file existed, so bblfshd might have crashed
if err := os.Remove(*ctl.address); err == nil {
logrus.Warningf("control socket %s (%s) already exists", *ctl.address, *ctl.network)
}
}
ctlListener, err = net.Listen(*ctl.network, *ctl.address)
if err != nil {
logrus.Fatalf("error creating control listener: %s", err)
Expand Down

0 comments on commit 5787893

Please sign in to comment.