tobiasehlert / teslamateapi

TeslaMateApi is a RESTful API to get data collected by self-hosted data logger TeslaMate in JSON
MIT License
94 stars 22 forks source link

Teslamateapi Container exits presumably since last update #250

Closed b1ggi closed 10 months ago

b1ggi commented 1 year ago

Hello,

my teslamateapi container exits since presumably last update

I stop all containers in the morning to backup and start them afterwards.

When I start the teslamateapi container manually it runs again normal.

When I start I can see the last error in the log:

2023-10-14T04:16:27.745442811+02:00 2023/10/14 04:16:27.745176 [info] TeslaMateApi running in release mode.
2023-10-14T04:16:27.758964007+02:00 2023/10/14 04:16:27.758875 dial tcp: lookup database on 127.0.0.11:53: no such host
2023-10-14T04:16:27.761218366+02:00 panic: dial tcp: lookup database on 127.0.0.11:53: no such host
2023-10-14T04:16:27.761241579+02:00 
2023-10-14T04:16:27.761244134+02:00 goroutine 1 [running]:
2023-10-14T04:16:27.761246589+02:00 log.Panic({0xc00031fcb8?, 0x957e60?, 0xc29840?})
2023-10-14T04:16:27.761249234+02:00     /usr/local/go/src/log/log.go:432 +0x5a
2023-10-14T04:16:27.761251568+02:00 main.initDBconnection()
2023-10-14T04:16:27.761253722+02:00     /go/src/webserver.go:214 +0x38c
2023-10-14T04:16:27.761256067+02:00 main.main()
2023-10-14T04:16:27.761258331+02:00     /go/src/webserver.go:51 +0x1ce
2023-10-14T04:16:28.661819971+02:00 2023/10/14 04:16:28.661723 [info] TeslaMateApi running in release mode.
2023-10-14T04:16:28.664119465+02:00 2023/10/14 04:16:28.664095 dial tcp: lookup database on 127.0.0.11:53: no such host
2023-10-14T04:16:28.666250073+02:00 panic: dial tcp: lookup database on 127.0.0.11:53: no such host
2023-10-14T04:16:28.666259250+02:00 
2023-10-14T04:16:28.666261454+02:00 goroutine 1 [running]:
2023-10-14T04:16:28.666263408+02:00 log.Panic({0xc00029fcb8?, 0x957e60?, 0xc29840?})
2023-10-14T04:16:28.666265612+02:00     /usr/local/go/src/log/log.go:432 +0x5a
2023-10-14T04:16:28.666267636+02:00 main.initDBconnection()
2023-10-14T04:16:28.666269499+02:00     /go/src/webserver.go:214 +0x38c
2023-10-14T04:16:28.666271553+02:00 main.main()
2023-10-14T04:16:28.666272986+02:00     /go/src/webserver.go:51 +0x1ce
2023-10-14T04:16:29.463428864+02:00 2023/10/14 04:16:29.463268 [info] TeslaMateApi running in release mode.
2023-10-14T04:16:30.502501571+02:00 2023/10/14 04:16:30.502002 [warning] initAuthToken - environment variable API_TOKEN not set or is empty.
2023-10-14T04:16:30.503089880+02:00 2023/10/14 04:16:30.502590 [info] getAllowList COMMANDS from environment variables set, allow_list.json will be ignored.
2023-10-14T04:16:30.505206151+02:00 2023/10/14 04:16:30.505159 [info] mqtt connecting...
2023-10-14T04:16:30.509171375+02:00 2023/10/14 04:16:30.509118 [error] TeslaMateApi MQTT connection failed: [error] TeslaMateAPICarsStatusV1 failed to connect to MQTT: network Error : dial tcp: lookup mosquitto on 127.0.0.11:53: no such host
2023-10-14T04:16:31.942204704+02:00 2023/10/14 04:16:31.941879 [info] TeslaMateApi running in release mode.
2023-10-14T04:16:31.945930400+02:00 2023/10/14 04:16:31.945865 [warning] initAuthToken - environment variable API_TOKEN not set or is empty.
2023-10-14T04:16:31.945950708+02:00 2023/10/14 04:16:31.945893 [info] getAllowList COMMANDS from environment variables set, allow_list.json will be ignored.
2023-10-14T04:16:31.945976486+02:00 2023/10/14 04:16:31.945926 [info] mqtt connecting...
2023-10-14T04:16:31.948589906+02:00 2023/10/14 04:16:31.948526 [error] TeslaMateApi MQTT connection failed: [error] TeslaMateAPICarsStatusV1 failed to connect to MQTT: network Error : dial tcp: lookup mosquitto on 127.0.0.11:53: no such host
2023-10-14T04:16:33.162059823+02:00 2023/10/14 04:16:33.161889 [info] TeslaMateApi running in release mode.
2023-10-14T04:16:33.165853737+02:00 2023/10/14 04:16:33.165781 [warning] initAuthToken - environment variable API_TOKEN not set or is empty.
2023-10-14T04:16:33.165869847+02:00 2023/10/14 04:16:33.165826 [info] getAllowList COMMANDS from environment variables set, allow_list.json will be ignored.
2023-10-14T04:16:33.166520933+02:00 2023/10/14 04:16:33.166484 [info] mqtt connecting...
2023-10-14T04:16:33.169929467+02:00 2023/10/14 04:16:33.169859 [error] TeslaMateApi MQTT connection failed: [error] TeslaMateAPICarsStatusV1 failed to connect to MQTT: network Error : dial tcp: lookup mosquitto on 127.0.0.11:53: no such host
2023-10-14T04:16:35.384239724+02:00 2023/10/14 04:16:35.384000 [info] TeslaMateApi running in release mode.
2023-10-14T04:16:35.387627890+02:00 2023/10/14 04:16:35.387578 [warning] initAuthToken - environment variable API_TOKEN not set or is empty.
2023-10-14T04:16:35.387641846+02:00 2023/10/14 04:16:35.387620 [info] getAllowList COMMANDS from environment variables set, allow_list.json will be ignored.

Corresponding docker-compose part:

teslamateapi:
    image: ghcr.io/tobiasehlert/teslamateapi:latest
    restart: on-failure:5
    depends_on:
      - database
      - teslamate
    environment:
      - ENCRYPTION_KEY=xxxxxx
      - DATABASE_USER=teslamate
      - DATABASE_PASS=secret
      - DATABASE_NAME=teslamate
      - DATABASE_HOST=database
      - MQTT_HOST=mosquitto
      - TZ=Europe/Berlin
      - ENABLE_COMMANDS=true
      - COMMANDS_ALL=true
      - API_TOKEN_DISABLE=true
    ports:
      - 18080:8080
    entrypoint: [ '/bin/sh', '-c', 'export DATABASE_PASS=$$(cat /run/secrets/db_password) ; ./app' ]
    secrets:
      - db_password
    networks:
      - teslamate 
b1ggi commented 1 year ago

I first try to increase restart-on-failure to 30 as a workaround

tobiasehlert commented 1 year ago

hello @b1ggi,

Interesting, the difference between 1.16.4 and 1.16.5 is not more than a golang bump and some mod. Have you made any changes to your host maybe? Both the connection to the database and the mqtt (mosquitto) seem to be failing due to DNS resolving (on port 53) is not working. Feels on the first look like some issue in Docker and not in the software itself.

Can you give it a try and specify the 1.16.4 container again to see if it works ok again? ghcr.io/tobiasehlert/teslamateapi:1.16.4

You can also give the edge labeled container an attempt as well, since it's includes an bump to Golang 1.21.3 as well. ghcr.io/tobiasehlert/teslamateapi:edge

Please also extend the logging a little more by setting DEBUG_MODE to true, that might tell us a little more.

Kind regards, Tobias

b1ggi commented 1 year ago

I try tomorrow, increasing the restart-on-failure worked as a workaround. Maybe just a specific problem for me.

tobiasehlert commented 10 months ago

hello @b1ggi,

Did your problem resolve or whats the status? :)

Kind regard, Tobias

b1ggi commented 10 months ago

I have no problems anymore, was specific to me maybe