Skip to content
This repository has been archived by the owner on Mar 22, 2019. It is now read-only.

go get on windows failed #15

Open
sergeyt opened this issue Jul 20, 2015 · 15 comments · May be fixed by #29
Open

go get on windows failed #15

sergeyt opened this issue Jul 20, 2015 · 15 comments · May be fixed by #29

Comments

@sergeyt
Copy link

sergeyt commented Jul 20, 2015

Running a go get github.com/facebookgo/grace/gracehttp gives me:

# github.com/facebookgo/grace/gracehttp
c:\gobits\src\github.com\facebookgo\grace\gracehttp\http.go:101: undefined: syscall.SIGUSR2
c:\gobits\src\github.com\facebookgo\grace\gracehttp\http.go:111: undefined: syscall.SIGUSR2
c:\gobits\src\github.com\facebookgo\grace\gracehttp\http.go:151: undefined: syscall.Kill
@daaku
Copy link
Contributor

daaku commented Aug 7, 2015

I think it's a fair request to have grace not fail on windows, even if it doesn't actually support graceful restart. I think this mode is a useful compromise for developers using windows but yet deploying to posix environments. I don't have a windows environment setup to work on this but happy to accept pull requests :)

@kristijan-ujevic
Copy link

any chance this will be fixed?

I have a windows development machine and i inherited a project that's dependent on this particular library so i can't do anything with it unless i dabble with the source of grace, but that's dirty as hell...

@daaku
Copy link
Contributor

daaku commented Aug 23, 2016

We're not currently working on windows support, but I'd be more than happy to review a pull request :)

@kristijan-ujevic
Copy link

kristijan-ujevic commented Aug 23, 2016

I'll see what i can do tomorrow :)

I have 2 options:
do a dirty edit and keep the file on git ignore just so i can get it running locally
or switch to Linux which would actually be ok.

Now I have a third, i'll look through the source more closely tomorrow and get back to you :)

@daaku
Copy link
Contributor

daaku commented Aug 23, 2016

What I would recommend, as the quickest fix, is to only add support for https://godoc.org/github.com/facebookgo/grace/gracehttp, which involves only 1 function, Serve, and provide a stub implementation for windows that just calls https://golang.org/pkg/net/http/#Server.ListenAndServe on all the servers. Assuming you don't want to deploy this to production, and are looking for windows support for your development environment, this will be a good enough fix. Good luck!

@ghost
Copy link

ghost commented Aug 24, 2016

@kristijan-ujevic here is as a demonstration of the approach @daaku has described above.

There are two files:

  • for win
// +build windows

package grace

import "net/http"

func Serve(s *http.Server) error {
    // The code will be a bit more complex when you add support
    // of Serve(s ...*http.Server).
    return s.ListenAndServe()
}
  • for nix
// +build !windows

package grace

import (
    "net/http"

    "github.com/facebookgo/grace/gracehttp"
)

func Serve(s *http.Server) error {
    return gracehttp.Serve(s)
}

That's it. Now the Serve method will use gracehttp by default and fall back to the standard net/http on Windows.

@kristijan-ujevic
Copy link

i'm not really sure what i need to do with this?

i'm somewhat new to Go, can you explain a bit further please? :)

@ghost
Copy link

ghost commented Aug 24, 2016

@kristijan-ujevic Read more about Build Constraints, that is the key here. You create 2 files with 2 different Serve functions: one for windows (that uses net/http), and another one for other platforms (that uses gracehttp).
Then you may use the created Serve function in your code as follows:

log.Fatal(Serve(&http.Server{
    Addr:   "...",
    Handler: ...,
}))

The package I've linked is just an illustration of this approach. You don't want to depend on it for such a simple use-case, but if you do here is a working code that will support graceful restarts and shutdowns on *nix based platforms and just work on windows:

package main

import (
    "log"

    "github.com/colegion/contrib/servers/grace"
)

func main() {
    s := &http.Server{...}
    log.Fatal(grace.Serve(s))
}

@ghost ghost linked a pull request Aug 25, 2016 that will close this issue
@bodyno
Copy link

bodyno commented May 23, 2017

Same issue

@Nasir13
Copy link

Nasir13 commented Aug 25, 2017

Anybody tell me what is this github

@Nasir13
Copy link

Nasir13 commented Aug 25, 2017

I have no idea about this

@Nasir13
Copy link

Nasir13 commented Aug 25, 2017

What i can do here yell me now

@bsed
Copy link

bsed commented Nov 7, 2017

go get github.com/facebookgo/grace/gracedemo

github.com/facebookgo/grace/gracehttp

..\github.com\facebookgo\grace\gracehttp\http.go:104:53: undefined: syscall.SIGUSR2
..\github.com\facebookgo\grace\gracehttp\http.go:114:8: undefined: syscall.SIGUSR2
..\github.com\facebookgo\grace\gracehttp\http.go:154:13: undefined: syscall.Kill

@windzhu0514
Copy link

SIGUSR2 is not define on windows ,just clone , set GOOS=linux ,go build

@ItsFunny
Copy link

same issue ,how could i restart the server in windows

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants