plotman icon indicating copy to clipboard operation
plotman copied to clipboard

plot command should reload config after sleeping (with alternate request)

Open markdomansky opened this issue 3 years ago • 10 comments

I would like plotman plot to be run as a background job using nohup (or in my specific case, as the docker entrypoint command). As a result, I want to be able to make changes to the plotman config without having to restart the background job.

I see 2 ways to do this:

  • Plotman re-reads the config after sleeping. This is probably best for most users so they don't need to know as much, but might require significant changes.
  • Add a parameter like plotman plot -q or plotman plot -n 5. -q in this case would run the plotting check and quit. -n 5 would run it 5 times (with the specified sleep in between) and then quit. In either scenario, I would set the docker entrypoint to be a loop with my own sleep timer.

otherwise, fantastic project and thank you!

markdomansky avatar May 15 '21 13:05 markdomansky

This comes up a lot, but I'm not convinced that this is a good thing to do. I do want to tend in the direction of plotman being used as a service with a separate monitor, but services don't generally reload configs on the fly in my (maybe too limited) experience.

But, there's probably a way to trigger a reload without shutting down if there's some significant reason to not shut down. The systemctl.service man page has some comments in the ExecReload section.

So there's sort of two bits to your request I think. I questioned automatic reloading above. Is there also significant value you see in reloading the configure without restarting plotman? If so, could you explain what it is to help me understand the case that you want handled a little better? If it were run as a service then, depending on your service manager, systemctl restart plotman or such would handle the restart plotman and load the new configuration. An extra feature to reload without restarting would just turn into systemctl reload plotman. reload seems like a proper thing to be able to do but it doesn't seem to affect the 'usability' much in this case.

altendky avatar May 15 '21 13:05 altendky

This is exactly what I'm missing as well. In my case i try to find the best plotting configuration and it is a annoying to kill running plots just to reload the configuration to run more or less plotting processes. Especially if they already run for 5 hours or so.

but services don't generally reload configs on the fly in my (maybe too limited) experience.

This is true but also depends on the use case. It would be also possible to add a configuration option for this some like enable-auto-reload = True

nook24 avatar May 16 '21 20:05 nook24

@nook24, closing plotman doesn't kill plot jobs.

altendky avatar May 17 '21 00:05 altendky

@altendky when you say "closing plotman", do you mean pressing ctrl+c on the screen instance?

m-ketan avatar May 17 '21 02:05 m-ketan

@altendky Could you explain how reload the configuration without breaking current plots?

carlo497 avatar May 17 '21 14:05 carlo497

@nook24, closing plotman doesn't kill plot jobs.

fyi: if plotman plot is your docker-entrypoint.. it will kill/restart your whole container including running plots

vidschofelix avatar May 17 '21 19:05 vidschofelix

If I sigterm plotman plot using ^C, change the configuration and start it again, will it pickup the old and still running plots and include them into the plot limit?

nook24 avatar May 17 '21 19:05 nook24

if you are not running inside docker it should work that way. Plotman is stateless and doesnt remain on anything like a database or something in ram... it just collects what it needs, so you can safely restart plotman.

vidschofelix avatar May 17 '21 20:05 vidschofelix

I'm running plotman in a container as well, if your entry point eventually goes to plotman plot you can very easily just do the following 1.) put a bash script in that goes in and initializes everything then eventually calls plotman, but background the loop

plotman plot &

and when you exit

you have the container waiting in a sleep listening for the termination

trap cleanup INT TERM
while :; do    sleep 1sdone

If you set the env up right you can docker exec in and just run your plotman commands ie

docker exec -it plotman plotman interactive
or 
docker exec -it plotman plotman status

See https://github.com/snoby/chia-docker for more examples ( FYI, I'm not backgrounding the plot loop yet)

snoby avatar Jun 01 '21 17:06 snoby

I'm running plotman in a container as well, if your entry point eventually goes to plotman plot you can very easily just do the following

Nice work! I solved it by making plot and archive configurable and let a loop run in entrypoint that starts plotman $command every 10 seconds if it isnt running. this way you can let the container do its thing, change config and reload config by simply docker-compose exec plotman bash -c "killall plotman". I should throw this into github aswell... Because with this its possible to use the plotman archiver under windows ^^

vidschofelix avatar Jun 01 '21 17:06 vidschofelix