sablierapp / sablier

Start your containers on demand, shut them down automatically when there's no activity. Docker, Docker Swarm Mode and Kubernetes compatible.
https://sablierapp.dev/
GNU Affero General Public License v3.0
1.46k stars 48 forks source link

workload shuts down while in use #391

Closed VamPikmin closed 2 months ago

VamPikmin commented 2 months ago

First of all, thank you so much for creating sablier

I've been trying to set it up but have come across an issue I can't seem to figure out on my own.

Setup: sablier plugin enabled in traefik,toml [experimental.plugins.sablier] moduleName = "github.com/acouvreur/sablier" version = "v1.8.0-beta.19

traefik_dynamic.toml

[http]
  [http.middlewares]
    [http.middlewares.sablier]
      [http.middlewares.sablier.plugin]
        [http.middlewares.sablier.plugin.sablier]
          group = "default"
          names = "filebrowser"
          sablierUrl = "http://sablier:10000"
          sessionDuration = "1m"

          [http.middlewares.sablier.plugin.sablier.dynamic]
            displayName = "Test message"
            refreshFrequency = "5s"
            showDetails = "true"
            theme = "shuffle"

[http.routers.filebrowser]
  rule = "Host(`filebrowser.domain`)"
  entrypoints = ["websecure"]
  middlewares = ["sablier"]
  service = "filebrowser"
  [http.services.filebrowser.loadBalancer]
  [[http.services.filebrowser.loadBalancer.servers]]
    url = "http://filebrowser"
  [http.routers.filebrowser.tls]
    certResolver = "lets-encrypt"

The container starts up fine with the "Test message" I am able to login to the webpage but after 1 min it shuts down even when in use.

I am actively browsing the web page and downloading a file.

I have also tried snapdrop docker, it appears to be also turning off after 1min

Context

Expected behavior I expected sablier not to shut the workload off because I'm actively downloading a file or browsing

Thank you for your time

acouvreur commented 2 months ago

Can you share the sablier container logs ?

It should not do that obviously :)

Also, you should use names or group exclusively.

names allow you to specify which containers to start/stop. group allows you to start/stop tagged containers with labels.

acouvreur commented 2 months ago

And maybe your session duration is too short ? Try with 10 minutes and you should be good.

VamPikmin commented 2 months ago

Hello, thank you for your reply and explaining the names and group usage :)

When I enable debug logs and keep refreshing the page it seems to function fine

time="2024-09-12T09:07:05Z" level=debug msg="map[default:[whoami snapdrop]]"
time="2024-09-12T09:07:07Z" level=debug msg="map[default:[whoami snapdrop]]"
time="2024-09-12T09:07:07Z" level=debug msg="starting snapdrop..."
time="2024-09-12T09:07:07Z" level=debug msg="starting whoami..."
time="2024-09-12T09:07:07Z" level=debug msg="status for whoami=not-ready"
time="2024-09-12T09:07:07Z" level=debug msg="status for snapdrop=not-ready"
time="2024-09-12T09:07:07Z" level=info msg="172.18.0.5 - 29f443b88ba4 [12/Sep/2024:09:07:07 +0000] \"GET /api/strategies/dynamic\" 200 4742 \"\" \"Go-http-client/1.1\" (286ms)" clientIP=172.18.0.5 dataLength=4742 hostname=29f443b88ba4 latency=286 method=GET path=/api/strategies/dynamic referer= statusCode=200 userAgent=Go-http-client/1.1
time="2024-09-12T09:07:08Z" level=debug msg="checking snapdrop..."
time="2024-09-12T09:07:08Z" level=debug msg="checking whoami..."
time="2024-09-12T09:07:08Z" level=debug msg="status for snapdrop=ready"
time="2024-09-12T09:07:08Z" level=debug msg="status for whoami=ready"
time="2024-09-12T09:07:08Z" level=info msg="172.18.0.5 - 29f443b88ba4 [12/Sep/2024:09:07:08 +0000] \"GET /api/strategies/dynamic\" 200 4734 \"\" \"Go-http-client/1.1\" (2ms)" clientIP=172.18.0.5 dataLength=4734 hostname=29f443b88ba4 latency=2 method=GET path=/api/strategies/dynamic referer= statusCode=200 userAgent=Go-http-client/1.1
time="2024-09-12T09:07:08Z" level=info msg="172.18.0.5 - 29f443b88ba4 [12/Sep/2024:09:07:08 +0000] \"GET /api/strategies/dynamic\" 200 4734 \"\" \"Go-http-client/1.1\" (1ms)" clientIP=172.18.0.5 dataLength=4734 hostname=29f443b88ba4 latency=1 method=GET path=/api/strategies/dynamic referer= statusCode=200 userAgent=Go-http-client/1.1
TRUNCATED
time="2024-09-12T09:10:45Z" level=debug msg="map[default:[whoami snapdrop]]"
time="2024-09-12T09:10:47Z" level=debug msg="map[default:[whoami snapdrop]]"
time="2024-09-12T09:10:49Z" level=debug msg="map[default:[whoami snapdrop]]"
time="2024-09-12T09:10:50Z" level=debug msg="stopping whoami..."
time="2024-09-12T09:10:50Z" level=debug msg="stopping snapdrop..."
time="2024-09-12T09:10:51Z" level=debug msg="stopped whoami"
time="2024-09-12T09:10:51Z" level=debug msg="received event instance whoami is stopped, removing from store"

I wonder if it's because when snapdrop webpage is loaded it gets cached- I don't see any of these info messages

time="2024-09-12T09:07:07Z" level=info msg="172.18.0.5 - 29f443b88ba4 [12/Sep/2024:09:07:07 +0000] \"GET /api/strategies/dynamic\" 200 4742 \"\" \"Go-http-client/1.1\" (286ms)" clientIP=172.18.0.5 dataLength=4742 hostname=29f443b88ba4 latency=286 method=GET path=/api/strategies/dynamic referer= statusCode=200 

So I can send messages from the snapdrop selfhosted website between devices and upload photos, however none of these seem to show up or register in sablier logs and maybe it thinks nothing is happening so it shuts down the container?

(If I load snapdrop and keep refreshing before the 1min timeout the page, container stays on)

Thank you for your time and help.

In any case I'll set the timeout to 10m, that should make it long enough to send a few photos

Have a great day

acouvreur commented 2 months ago

The middleware are only compatible with HTTP protocole, if you're switching to another protocol: grpc, websocket, plain tcp, etc. It won't be seen by the middleware unfortunately. Maybe that's what's happening ? It's possible that once snapdrop is loaded, everything is done through a websocket.

VamPikmin commented 2 months ago

I am using traefik to reverse proxy the snapdrop container

It appears that snapdrop is built using WebRTC and fallsback to websockets so that might explain it

Thank you again for all your help acouvreur