bitmagnet-io / bitmagnet

A self-hosted BitTorrent indexer, DHT crawler, content classifier and torrent search engine with web UI, GraphQL API and Servarr stack integration.
https://bitmagnet.io/
MIT License
1.96k stars 74 forks source link

Windows fixes: Implement Windows Socket interface and recover from socket read error #203

Closed mgdigital closed 2 months ago

djdv commented 2 months ago

Referencing this from the previous pull: https://github.com/bitmagnet-io/bitmagnet/pull/144#issuecomment-1985699351

mgdigital commented 2 months ago

Could you see if this branch works better for you @vadimkim?

vadimkim commented 2 months ago

Can't build. Error:

C:\Users\vadim\Projects\bitmagnet>go build
go: downloading github.com/go-resty/resty/v2 v2.11.0
# github.com/bitmagnet-io/bitmagnet/internal/protocol/dht/server
internal\protocol\dht\server\socket_windows.go:57:12: undefined: syscall
mgdigital commented 2 months ago

Can't build. Error:

C:\Users\vadim\Projects\bitmagnet>go build
go: downloading github.com/go-resty/resty/v2 v2.11.0
# github.com/bitmagnet-io/bitmagnet/internal/protocol/dht/server
internal\protocol\dht\server\socket_windows.go:57:12: undefined: syscall

Sorry could you try it again that error should be fixed? I literally can't validate this myself!

djdv commented 2 months ago

@mgdigital The go tools will read the GOOS environment variable which can help when testing code for other platforms. E.g. $GOOS=windows go vet ./... on a Linux system, should catch that issue. go vet usually works to make sure a package has no syntax issues. And as long as you don't have too many platform specific dependencies go build can often produces a working binary for that GOOS target.

vadimkim commented 2 months ago

I imported "syscall" and compiled, no problem with that. You just need to add this import to source code. Testing right now. Let me have couple of days to look closely on behaviour.

vadimkim commented 2 months ago

Preliminary results:

mgdigital commented 2 months ago

Thanks. It looks encouraging. That error you posted looks like the queue has lost its connection to the database for a while. If you can still see new torrents appearing that means the queue is working....

I expect the error code fix here is only going to help Windows users running from a .exe file. Docker for Windows users have also been reporting issues but their OS will be reported as Unix, and as with the Anacrolix fix here this bit won't be triggered for them: https://github.com/anacrolix/dht/blob/master/errnos_windows.go. Do you have any insight on this @djdv ? And @vadimkim I expect if you build this branch as a Docker image you'll still be seeing issues with that, do you still see the same Socket read error?

vadimkim commented 2 months ago

I finished testing this code and have experienced the reported error in preliminary results twice. From the command line everything works and I was able to download around 300k DHTs during weekend. @mgdigital do you want me to build docker image with bitmagnet.exe inside? Can you suggest me what Docker image to take as base image?

mgdigital commented 2 months ago

Thanks @vadimkim , lets get this PR merged and come back to the Docker stuff - it will just be using the ghcr image, I expect there might still be Windows issues.