solectrus / hosting

Step-by-stypes guides for installing and hosting Solectrus
9 stars 4 forks source link

solectrus-app-1 status unhealthy #44

Closed loebse closed 4 months ago

loebse commented 4 months ago

Hi @ledermann,

auch wenn ich schon länger nicht mehr aktiv war, verfolge ich doch weiterhin alle Entwicklung mit großer Freude 😉

Aktuell habe ich jedoch folgendes Problem: der Status des solectrus-app-1 Containers steht immer auf `ùnhealthy``.

In den Logs kann ich allerdings nicht wirklich einen Fehler erkennen. Ist Dir das bekannt bzw. kannst du den Grund erkennen? Funktional scheint soweit alles in Ordnung zu sein.

Starting SOLECTRUS...
Version: v0.14.4 - 2024-03-21T11:01:57+01:00 - v0.14.4
----------------
redis (192.168.160.4:6379) open
Redis is up and running!
influxdb (192.168.160.3:8086) open
InfluxDB is up and running!
PostgreSQL is up and running!
Preparing database...
db (192.168.160.2:5432) open
Database is ready!
=> Booting Puma
=> Rails 7.1.3.2 application starting in production 
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 6.4.2 (ruby 3.3.0-p0) ("The Eagle of Durango")
*  Min threads: 5
*  Max threads: 5
*  Environment: production
*          PID: 1
* Listening on http://0.0.0.0:3000
Use Ctrl-C to stop
I, [2024-04-12T07:46:08.278352 #1]  INFO -- : [192.168.1.133] method=GET path=/inverter_power/now format=html controller=HomeController action=index status=200 allocations=109180 duration=334.82 view=322.67 db=9.66
I, [2024-04-12T07:46:08.463326 #1]  INFO -- : [192.168.1.133] method=GET path=/stats/inverter_power/now format=html controller=StatsController action=index status=200 allocations=38372 duration=94.27 view=93.91 db=0.00
I, [2024-04-12T07:46:08.490506 #1]  INFO -- : [192.168.1.133] method=GET path=/charts/inverter_power/now format=html controller=ChartsController action=index status=200 allocations=57195 duration=119.90 view=119.63 db=0.00
I, [2024-04-12T07:46:13.414860 #1]  INFO -- : [192.168.1.133] method=GET path=/stats/inverter_power/now format=html controller=StatsController action=index status=200 allocations=13060 duration=35.35 view=35.05 db=0.00
I, [2024-04-12T07:46:16.838717 #1]  INFO -- : [192.168.1.133] method=GET path=/settings format=html controller=SettingsController action=edit status=200 allocations=30071 duration=52.35 view=37.25 db=14.08
I, [2024-04-12T07:46:19.493366 #1]  INFO -- : [192.168.1.133] method=GET path=/settings/prices/electricity format=html controller=PricesController action=index status=200 allocations=30197 duration=47.94 view=30.80 db=6.77
I, [2024-04-12T07:46:21.810757 #1]  INFO -- : method= path= format= params={} controller=ApplicationCable::Connection action=connect status=200 allocations=310 duration=0.64
I, [2024-04-12T07:46:21.812886 #1]  INFO -- : method= path= format= params= controller=Turbo::StreamsChannel action=subscribe status=200 allocations=155 duration=0.31
I, [2024-04-12T07:46:22.038529 #1]  INFO -- : [192.168.1.133] method=GET path=/settings/prices/feed_in format=html controller=PricesController action=index status=200 allocations=14647 duration=22.24 view=19.54 db=0.92
I, [2024-04-12T07:46:25.840267 #1]  INFO -- : method= path= format= params= controller=Turbo::StreamsChannel action=unsubscribe status=200 allocations=85 duration=0.22
I, [2024-04-12T07:46:25.849464 #1]  INFO -- : method= path= format= params= controller=Turbo::StreamsChannel action=subscribe status=200 allocations=55 duration=0.20
I, [2024-04-12T07:46:27.433676 #1]  INFO -- : [192.168.1.133] method=GET path=/settings/prices/electricity format=html controller=PricesController action=index status=200 allocations=15491 duration=31.96 view=29.47 db=1.06
I, [2024-04-12T07:46:27.771296 #1]  INFO -- : [192.168.1.133] method=GET path=/settings format=html controller=SettingsController action=edit status=200 allocations=14322 duration=20.70 view=20.10 db=0.00
I, [2024-04-12T07:46:27.984752 #1]  INFO -- : method= path= format= params= controller=Turbo::StreamsChannel action=unsubscribe status=200 allocations=42 duration=0.17
I, [2024-04-12T07:46:28.264387 #1]  INFO -- : [192.168.1.133] method=GET path=/ format=html controller=HomeController action=index status=302 allocations=1972 duration=14.67 view=0.00 db=0.00 location=http://192.168.1.41:3003/inverter_power/now
I, [2024-04-12T07:46:28.317555 #1]  INFO -- : [192.168.1.133] method=GET path=/inverter_power/now format=html controller=HomeController action=index status=200 allocations=17214 duration=46.74 view=46.32 db=0.00
I, [2024-04-12T07:46:28.652787 #1]  INFO -- : [192.168.1.133] method=GET path=/stats/inverter_power/now format=html controller=StatsController action=index status=200 allocations=25054 duration=77.27 view=76.99 db=0.00
I, [2024-04-12T07:46:28.680561 #1]  INFO -- : [192.168.1.133] method=GET path=/charts/inverter_power/now format=html controller=ChartsController action=index status=200 allocations=43984 duration=101.43 view=101.18 db=0.00
I, [2024-04-12T07:46:28.830163 #1]  INFO -- : [192.168.1.133] method=GET path=/essentials format=html controller=EssentialsController action=index status=200 allocations=18153 duration=31.01 view=30.27 db=0.00
I, [2024-04-12T07:46:29.198686 #1]  INFO -- : [192.168.1.133] method=GET path=/inverter_power/all format=html controller=HomeController action=index status=200 allocations=17708 duration=29.47 view=28.89 db=0.00
I, [2024-04-12T07:46:56.523327 #1]  INFO -- : [192.168.1.133] method=GET path=/stats/inverter_power/now format=html controller=StatsController action=index status=200 allocations=24351 duration=71.76 view=71.54 db=0.00
I, [2024-04-12T07:46:56.543554 #1]  INFO -- : [192.168.1.133] method=GET path=/charts/inverter_power/now format=html controller=ChartsController action=index status=200 allocations=44868 duration=93.41 view=93.11 db=0.00
I, [2024-04-12T07:46:59.139440 #1]  INFO -- : [192.168.1.133] method=GET path=/stats/inverter_power/now format=html controller=StatsController action=index status=200 allocations=24001 duration=45.75 view=45.41 db=0.00
I, [2024-04-12T07:46:59.159248 #1]  INFO -- : [192.168.1.133] method=GET path=/charts/inverter_power/now format=html controller=ChartsController action=index status=200 allocations=45396 duration=74.20 view=73.89 db=0.00
I, [2024-04-12T07:47:03.708385 #1]  INFO -- : [192.168.1.133] method=GET path=/essentials format=html controller=EssentialsController action=index status=200 allocations=11341 duration=22.17 view=21.83 db=0.00
I, [2024-04-12T07:47:03.919551 #1]  INFO -- : [192.168.1.133] method=GET path=/tiles/inverter_power/now format=html controller=TilesController action=show status=200 allocations=16536 duration=37.94 view=36.07 db=0.00
I, [2024-04-12T07:47:03.929684 #1]  INFO -- : [192.168.1.133] method=GET path=/tiles/inverter_power/day format=html controller=TilesController action=show status=200 allocations=15305 duration=39.89 view=36.00 db=3.54
I, [2024-04-12T07:47:04.017393 #1]  INFO -- : [192.168.1.133] method=GET path=/tiles/inverter_power/month format=html controller=TilesController action=show status=200 allocations=23412 duration=125.19 view=111.17 db=13.76
I, [2024-04-12T07:47:04.321201 #1]  INFO -- : [192.168.1.133] method=GET path=/tiles/inverter_power/year format=html controller=TilesController action=show status=200 allocations=25121 duration=424.67 view=414.30 db=10.04
I, [2024-04-12T07:47:04.326046 #1]  INFO -- : [192.168.1.133] method=GET path=/tiles/co2_savings/year format=html controller=TilesController action=show status=200 allocations=25348 duration=425.46 view=410.36 db=14.71
I, [2024-04-12T07:47:04.467308 #1]  INFO -- : [192.168.1.133] method=GET path=/tiles/savings/year format=html controller=TilesController action=show status=200 allocations=8058 duration=338.91 view=338.20 db=0.36
I, [2024-04-12T07:47:04.672337 #1]  INFO -- : [192.168.1.133] method=GET path=/inverter_power/day format=html controller=HomeController action=index status=200 allocations=17936 duration=37.29 view=36.81 db=0.00
I, [2024-04-12T07:47:06.663022 #1]  INFO -- : [192.168.1.133] method=GET path=/top10/day/inverter_power/sum/desc format=html controller=Top10Controller action=index status=200 allocations=24716 duration=58.12 view=57.03 db=0.00
I, [2024-04-12T07:47:06.965774 #1]  INFO -- : [192.168.1.133] method=GET path=/top10-chart/day/inverter_power/sum/desc format=html controller=Top10ChartController action=index status=200 allocations=13815 duration=105.58 view=105.15 db=0.00
I, [2024-04-12T07:47:07.586150 #1]  INFO -- : [192.168.1.133] method=GET path=/ format=html controller=HomeController action=index status=302 allocations=697 duration=1.41 view=0.00 db=0.00 location=http://192.168.1.41:3003/inverter_power/now
I, [2024-04-12T07:47:07.616890 #1]  INFO -- : [192.168.1.133] method=GET path=/inverter_power/now format=html controller=HomeController action=index status=200 allocations=17215 duration=24.96 view=24.31 db=0.00
I, [2024-04-12T07:47:07.986140 #1]  INFO -- : [192.168.1.133] method=GET path=/stats/inverter_power/now format=html controller=StatsController action=index status=200 allocations=16769 duration=37.77 view=37.00 db=0.00
I, [2024-04-12T07:47:08.034278 #1]  INFO -- : [192.168.1.133] method=GET path=/charts/inverter_power/now format=html controller=ChartsController action=index status=200 allocations=44003 duration=83.68 view=83.47 db=0.00
I, [2024-04-12T07:47:12.979803 #1]  INFO -- : [192.168.1.133] method=GET path=/stats/inverter_power/now format=html controller=StatsController action=index status=200 allocations=13118 duration=32.61 view=32.31 db=0.00
ledermann commented 4 months ago

Wenn SOLECTRUS mit "großer Freude" korreliert, finde ich das immer gut ;-)

Bei der Container-Gesundheit ist es so, dass es bis Version 0.14.3 einen integrierten HealthCheck gab, also fest eingebacken im Docker Image. Das habe ich aber mit Version 0.14.4 herausgenommen, weil ein HealtCheck im docker-compose.yml besser aufgehoben ist. Wenn man dann im docker-compose.yml keinen Eintrag für services.app.healthcheck hat, dann ist der Container-Status nach dem Start nur up und kann auch gar nicht unhealthy werden.

Im Hosting Guide wird diese Einstellung als Teil der docker-compose.yml vorgeschlagen:

healthcheck:
  test: ['CMD-SHELL', 'nc -z 127.0.0.1 3000 || exit 1']

Ich habe das gerade nochmal mit Version 0.14.4 ausprobiert, es funktioniert problemlos. Und zwar mit und ohne healthcheck in der docker-compose.yml.

Wenn bei dir der Status unhealthy ist, dann befindet sich vermutlich in der docker-compose ein ungültiger healthcheck. Was genau steht dann da bei dir?

loebse commented 4 months ago

Vielleicht übersehe ich was, aber der health check sollte korrekt in meiner docker-compose.yamlsein:

services:
  app:
    image: ghcr.io/solectrus/solectrus:latest
    depends_on:
      db:
        condition: service_healthy
      influxdb:
        condition: service_healthy
      redis:
        condition: service_healthy
    links:
      - db
      - influxdb
      - redis
    ports:
      - 3003:3000
    environment:
      - APP_HOST
      - FORCE_SSL
      - SECRET_KEY_BASE
      - INSTALLATION_DATE
      - ELECTRICITY_PRICE
      - FEED_IN_TARIFF
      - ADMIN_PASSWORD
      - DB_HOST=db
      - DB_PASSWORD=${POSTGRES_PASSWORD}
      - DB_USER=postgres
      - REDIS_URL=redis://redis:6379/1
      - INFLUX_HOST
      - INFLUX_TOKEN=${INFLUX_TOKEN_READ}
      - INFLUX_ORG
      - INFLUX_BUCKET
      - INFLUX_MEASUREMENT_PV
      - INFLUX_MEASUREMENT_FORECAST
      - INFLUX_POLL_INTERVAL
      - WEB_CONCURRENCY
    healthcheck:
      test: ['CMD-SHELL', 'nc -z 127.0.0.1 3003 || exit 1']
    restart: always
    logging:
      options:
        max-size: '10m'
        max-file: '3'

Da fällt mir gerade auf, dass ich - ELECTRICITY_PRICE und - FEED_IN_TARIFF entfernen sollte 😉

ledermann commented 4 months ago

Es liegt am Port. Es muss 3000 angegeben werden, nicht 3003. Der von Dir festgelegte Port 3003 gilt nur für den Zugriff von außerhalb, der HealthCheck wird aber im Container ausgeführt.

Es muss also heißen:

healthcheck:
  test: ['CMD-SHELL', 'nc -z 127.0.0.1 3000 || exit 1']

Und ja, ELECTRICITY_PRICE und FEED_IN_TARIFF können weg, die stammen noch aus grauer Vorzeit ;-)

loebse commented 4 months ago

Ohje, da sitzt das Problem mal wieder VOR dem Monitor 🤣

Danke Dir für die schnelle Hilfe! Macht natürlich Sinn, dass die Abfrage auf den internen Port 3000 geht.

loebse commented 4 months ago

Funktioniert so einwandfrei 👍