AnalogJ / scrutiny

Hard Drive S.M.A.R.T Monitoring, Historical Trends & Real World Failure Thresholds
MIT License
4.72k stars 154 forks source link

[BUG] Hardcoded http port does not play nice with changing the bound port #599

Closed Xeboc closed 1 month ago

Xeboc commented 3 months ago

Describe the bug A startup script uses a hard coded port to run the collector service once on startup: https://github.com/AnalogJ/scrutiny/blob/master/rootfs/etc/services.d/collector-once/run#L10

This does not play nice with changing the port in the config file: https://github.com/AnalogJ/scrutiny/blob/master/example.scrutiny.yaml#L21

And causes an endless wait state:

scrutiny  | scrutiny api not ready
scrutiny  | scrutiny api not ready
scrutiny  | scrutiny api not ready
...

Expected behavior Changing the port in the config file is picked up by the startup script. Maybe an ENV parameter will cover this? Or the startup script can be disabled? Or multiple ports can be defined? Or...?

Screenshots N/A

Log Files N/A

aidan-gibson commented 1 month ago

In lots of places https://github.com/search?q=repo%3AAnalogJ%2Fscrutiny+8080+AND+NOT+path%3A*.md&type=code

Annoying bug would be trivial to patch, no time to do myself rn unfortunately.

AnalogJ commented 1 month ago

hm, can you help me understand the issue here?

That file is only used when running the collector in Docker. In which case you shouldn't need to update the port (instead just bind the external port to a different number -p 9090:8080

aidan-gibson commented 1 month ago

Oh sweet I'm crazy, it works! Sorry, I had tried this some months ago and changing the port in my docker compose wasn't successful, and I assumed this was the same issue without testing. Sorry about that! Lovely software, thanks a ton for making this!

AnalogJ commented 1 month ago

great! closing :)

Xeboc commented 1 month ago

Not sure why my bug report was hijacked and closed here.

I don't use direct host networking running docker files (my default bridge is disabled) and instead assign an individual bridge subnet and separate IP addresses for each container. This allows for greater network isolation on a server running many docker images. The suggestion to simply bind the port doesn't work in my case, which is why I filed the bug report.

Given this docker-compose.yaml:

services:
  scrutiny:
    image: ghcr.io/analogj/scrutiny:master-omnibus
    container_name: scrutiny
    cap_add:
      - SYS_RAWIO
    volumes:
      - /run/udev:/run/udev:ro
      - ./config:/opt/scrutiny/config
      - ./influxdb:/opt/scrutiny/influxdb
    networks:
      network:
        ipv4_address: "172.18.1.2"
        aliases:
          - scrutiny
    ports:
      - "172.18.1.2:<any port>:8080"
    devices:
      - "/dev/sda"
    restart: always

networks:
  network:
    driver: bridge
    driver_opts:
      com.docker.network.bridge.name: br-scrutiny
    enable_ipv6: false
    ipam:
      driver: default
      config:
        - subnet: 172.18.1.0/24

Any port binding to the ip will fail:

Error response from daemon: driver failed programming external connectivity on endpoint
scrutiny (<container id>): Error starting userland proxy: listen tcp4 172.18.1.2:<any port>:
bind: cannot assign requested address

So I change the IP address in the configuration file, which works fine, except for the startup script uses a hard coded value, rather than reading it from the config file. I'm simply requesting that the startup script reads the port from the config file rather than be hard coded.