ItsEcholot / ContainerNursery

Puts Docker Containers to sleep and wakes them back up when they're needed
MIT License
130 stars 7 forks source link

feature request : pause/start #40

Open warlordattack opened 1 year ago

warlordattack commented 1 year ago

Would be nice to be able to choose to "PAUSE/RESUME" instead of "STOP/start" behaviour :) In some cases it is not necessary to completely stop the containers, pause/play is very responsive compared to full stop/start.

2022-12-01_155815

ItsEcholot commented 1 year ago

ContainerNursery's primary goal is to save memory, as far as I know pausing a container keeps it in memory thus making it rather useless for this objective. This being said, it could be useful for trying to save only some CPU. I would be open to accepting a PR for this functionality, but I don't think I will find the time in the near future to implement this myself.

warlordattack commented 1 year ago
I have 16gb ram in my nas and 128gb ram in my PC.
I am more interested in responsivness (fast pause/start) instead of ram gain.

Perhaps an option (per site) in the config.yml ? : 
pauseStop = 
stop (default -> stop/start : save RAM, but more delay to start)  
or
pause (second possible behaviour : pause/play : loose some RAM but faster start)

example : 
proxyHosts:
  - domain: dn-petio.monsite.ovh
    containerName: g-petio
    proxyHost: glu # gluetun hostname
    proxyPort: 7777 # petio port in gluetun
    timeoutSeconds: 300 # 5 min
    pauseStop: pause

So by default there would not be any change in the config file, the option would default to actual behaviour wich is stop/start.
If i need fast start for one site, in my config.yml file i would add pauseStop=pause (only for this site), and this would change this site behaviour to play/pause instead of full stop/start.

Best regards :)
scobby commented 9 months ago

+1 from me

Hi, having the same problem. Having much RAM and want to save CPU time to make other services more responsive. As far as i know its the only working service with nginx proxy manager. Sablier is a similar project, but only works with plain nginx.

Isnt it just to implement a variabel per Domain to select pause/stop and use this variable in the docker command?

ItsEcholot commented 9 months ago

@scobby: It might be that easy, feel free to look into this and create a pull request if you're interested in this feature. Since this doesn't fit my particular use case I probably won't invest time in it.

One thing to consider also is how to handle any external (out of ContainerNurserys control) pausing / stopping. Currently this works by listening to the Docker event stream, I'm guessing pausing could be handled similarly?

scobby commented 9 months ago

@ItsEcholot my node.js is not so brilliant, i just changed a few lines in the code

exchanged state.running with a check on the Status = "running". this is for check if the container is really running. And exchanged "stop" with "pause" and "start" with "unpause". Works for me, maybe someone can make this configurable.

from the documentation https://docs.docker.com/engine/api/v1.37/#tag/Container/operation/ContainerInspect hen pausing a container (on Linux), the cgroups freezer is used to suspend all processes in the container. Freezing the process requires the process to be running. As a result, paused containers are both Running and Paused. Use the Status field instead to determine if a container's state is "running".