ItsEcholot / ContainerNursery

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

Stating other containers when using multiple container names #38

Open kn-f opened 2 years ago

kn-f commented 2 years ago

When I connect to a proxy'd server that requires at least two containers to be active and one of them is common in other configurations, all the containers with the common container are started. Example:

proxyHosts:
  - domain: aaa.example.com
    containerName:
      - aaaa
      - common
    proxyHost: aaaa
    proxyPort: 1234
    timeoutSeconds: 180
    stopOnTimeoutIfCpuUsageBelow: 50
  - domain: bbb.example.com
    containerName:
      - bbbb
      - common
    proxyHost: bbbb
    proxyPort: 5678
    timeoutSeconds: 180
    stopOnTimeoutIfCpuUsageBelow: 50

If I connect to aaa.example.com ContainerNurse, in order:

Extract from the log file:

    DEBUG [2022-09-07 08:28:27.567 +0000]: Proxied request host: "aaa.example.com"
    INFO [2022-09-07 08:28:29.438 +0000]: Starting container 
    container: "aaaa"
    INFO [2022-09-07 08:28:29.462 +0000]: Starting container
    container: "common"
    [..]
    DEBUG [2022-09-07 08:28:36.701 +0000]: Starting container complete
    container: "aaaa"
    INFO [2022-09-07 08:28:36.705 +0000]: Starting container
       container: "aaaa"
    INFO [2022-09-07 08:28:36.710 +0000]: Starting container
    container: "bbbb"

Is this an expected behaviour? If yes are you aware of an alternate solution I could use to solve this?

The use case scenario is: I have several containers that use services from another container (mysql). If all the containers are down, the common container can be stopped. If any of the container is up, the common container should be started.