alexjustesen / speedtest-tracker

Speedtest Tracker is a self-hosted internet performance tracking application that runs speedtest checks against Ookla's Speedtest service.
https://speedtest-tracker.dev/
MIT License
2.8k stars 107 forks source link

Running multiple instances #555

Closed jtambasco closed 1 year ago

jtambasco commented 1 year ago

Describe the bug In docker-compose, I have made two instances of speedtest-tracker in a docker-compose:

speedtest-tracker:
      container_name: speedtest_tracker
      ports:
          - 6543:80
          - 6443:443
      environment:
          - PUID=1000
          - PGID=1000
      volumes:
          - ./speedtest-tracker:/config
      image: ghcr.io/alexjustesen/speedtest-tracker:latest
      restart: unless-stopped

speedtest-tracker-gluetun:
      container_name: speedtest_tracker_gluetun
      environment:
          - PUID=1000
          - PGID=1000
      volumes:
          - ./speedtest-tracker-gluetun:/config
      image: ghcr.io/alexjustesen/speedtest-tracker:latest
      network_mode: service:gluetun
      restart: unless-stopped

One of them is to report the speed of my home network, while the other is to report the speed of my home network via some VPN configured in gluetun. It works quite well, with both instances accessible via their respective http(s) ports. When I open both instances at the same time, the web browser forces me to refresh the webpage of one of the instances, and proceeds to log me out of that instance. It then takes a couple of tries to re-log back into that instance, before one of the instances again logs out. The problem only happens if I open both instances.

I assume this is a bug?

Expected behaviour Not get logged out when opening 2 instances. or I guess a workaround would be if somehow the one instance was able to check the speed of both networks, but this sounds like it'd be a lot of work.

Environment

brum74 commented 1 year ago

I run two instances (local and vpn) as well and ran into this also until I put them behind nginx proxy manager.

alexjustesen commented 1 year ago

Do you run them with a shared DB or separate?

jtambasco commented 1 year ago

I just used the default settings, so I assume they're running with a shared DB? From the installation page, it's unclear to me whether one can use sqlite and have two separate DBs. I tried adding - DB_DATABASE=... to hopefully use different DB, but it didn't work with sqlite. Should I be using mariadb or postgres instead? Or is it possible to make it work with sqlite?

alexjustesen commented 1 year ago

Last question, your mounted volume the same location? If not then it's two different DBs

jtambasco commented 1 year ago

I use what's in the docker-compose I attached. For one instance I have: ./speedtest-tracker-gluetun:/config and for the other I have ./speedtest-tracker:/config so I assume they should be different DBs?

alexjustesen commented 1 year ago

Yeah those are different, I'll dig into it as this might be just a case of the session colliding.

alexjustesen commented 1 year ago

@jtambasco so you're going to want to override the APP_NAME environment variable to prevent the sessions from colliding. I suggest passing the 2nd container something like APP_NAME="Speedtest Tracker for VPN" or something like that.

Source for cookie name which determines session https://github.com/alexjustesen/speedtest-tracker/blob/main/config/session.php#L118-L132