rclone
rclone copied to clipboard
add ability to signal rclone to finish current partial task and exit
It'd be convenient to be able to signal rclone (perhaps via a SIGUSR1 or SIGUSR2?) to finish up working on the current transfers and then exit so uploads aren't left in a half state. Or perhaps SIGINT? One ctrl-c on the terminal or from external source could tell it to finish up and exit while a second SIGINT would instruct it to exit immediately.
Nice idea.
+1
I agree. If you issue the "brake" command you could be presented with, "finish task or abort" this suggestion for those of us who use key strokes or what not to control our screen sessions.
Anothr thing, finish task could be keyed to f and abort could be keyed to a or something like that.
Yes please!
For interactive use I think the first Ctrl+C (SIGINT) for soft abort and second for hard abort works best. For non-interactive use one could probably just send SIGINT for soft abort and SIGTERM for hard abort.
I adhere to this feature request. Another approach could be to put some "flag" that could be read from time to time, for example if you put a file in the same folder where rclone.exe resides, named stop.txt, after X minutes Rclone could look up if there is the file and then to gracefully stop after end the current file being transfered. Maybe is not the most elegant solution but it's handy.
This could be an API call too...
This would be a great feature to have for some use cases here; I suggest implementing it via the remote control server (ie, --rc) functionality.
I was able to figure out a workaround using socat as a “session manager” for graceful shutdown. example:
rclone serve sftp --addr :8022 local:/my_dir/ can be used to host the /my_dir folder with SFTP
socat TCP-LISTEN:2022,fork,reuseaddr TCP-CONNECT:127.0.0.1:8022 was used to proxy connections to the real rclone instance.
socat would start with a certain pid (eg. 150) when an sftp session was opened, socat would “move” the traffic proxy into a new process (eg. 151). Then a SIGTERM signal could be sent to the original process (150) and the container would stop accepting new connections. The child processes can then be monitored using something like ps and will stay open until the client disconnects. Once that happens, the rclone process can be safely terminated.
Here's a gist with a basic script that does this: https://gist.github.com/ColinHeathman/ffd441f292a1e42c92835b6d639ec5a5