anthonyraymond / joal

An open source command line RatioMaster with an optional WebUI.
Apache License 2.0
595 stars 64 forks source link

Graceful shutdown doesn't announce all torrents #203

Closed lidivoth closed 1 year ago

lidivoth commented 1 year ago

Hi.

I've noticed that when exiting (ctrl+c, kill PID, etc.) that Joal starts a graceful shutdown and starts to announce that to the trackers for the torrent, but it gets ~20ish torrents in the stops. Currently have more than that.

To replicate, load up quite a few torrents (I have 100+) then issue command line shutdown.

I realise that through the webui I could just click stop then shut down (I've confirmed that that works fine), but I'm wanting to automate shutdown/restart Joal. The reason I'm wanting to do this is because a big portion of the torrents have partial seeders which are treated like leeches (no idea how you'd logically differentiate leeches from partial seeders, maybe monitor peer relevance/percentage complete...), so wanting to periodically stop that upload session and create a new one so that I don't become the lead seeder in the swarm.

Thought about automating sending a command to the webui to stop/restart Joal but have no idea how to do that.

Thanks, lidivoth

anthonyraymond commented 1 year ago

Hello,

I'm aware about that, it's by design. It put all torrent in queue for announce stop and process them 5 by 5. If the whole process takes more than x seconds (5 or 10 i can't remember exactly), it shutdowns abrubtly without waiting.

I didn't wanted the app to takes forever to close if a torrent was taking too long (because of a tcp timeout or whatever). That's the reason why it works like that.

I don't think being elected "lead seeder" is just a matter of the time stayed uploading. When you start seeding or downloading in JOAL (or any other client). JOAL first send a message to the tracker saying: "Hey there, i'm available for XXXX.torrent, i have downloaded xxx bytes, and i still have xxx bytes to download in order to complete."

So whatever you do, the trackers knows if are a partial seeder or not. Stopping multiple times a day won't change that.

If you still want to do so, you could be able to program a simple websocket client that issue request to the joal server but i would require quite a bit a work.

lidivoth commented 1 year ago

Hi,

That makes total sense not wanting to wait if it is hanging while shutting down. Is there a way for me to manually increase the time that it waits?

I don't think I did a good job of explaining what I was meaning by being the top seeder for the upload session. I'm not talking about me being a partial seeder.

Most trackers in the peer list for a torrent will list the peer's upload amount for that session. Now, if there are partial seeders then Joal will seed indefinitely. This means that after a while my upload will be the highest on the peer list to the point that it is ridiculously higher than the next highest peer. Which really isn't how to hide.

So by stopping seeding it via Joal will stop that session and start another one, putting you at the bottom of the peer list upload amount.

Does that make more sense?

anthonyraymond commented 1 year ago

Ok i see what you mean.

The max shutdown times is defined at: https://github.com/anthonyraymond/joal/blob/e9edb5e960ff056bbc805aa868e9f906850da7b8/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/request/AnnouncerExecutor.java#L77

i guess i could externalize this value to a configuration file, but i'm quite a bit busy ATM :/

lidivoth commented 1 year ago

Perfect. I managed to extend the time out and it's working great now.

It might be useful to have it in the configuration file.

Understandable, thanks for taking the time to point me in the right direction.

Thanks, lidivoth

anthonyraymond commented 1 year ago

I'll try to improve that in next versions :)