Bepacom-Raalte / bepacom-HA-Addons

Repository for Bepacom EcoPanel add-ons for Home Assistant.
Apache License 2.0
15 stars 2 forks source link

Addon does not start: s6-rc: warning: unable to start service init-nginx: command exited 1 #29

Closed jaymemaurice closed 11 months ago

jaymemaurice commented 12 months ago

Nginx seems to start when launching from docker run but seems to be unhappy when starting through my supervised home assistant:

Add-on version: 1.1.4 You are running the latest version of this add-on. System: Debian GNU/Linux 11 (bullseye) (amd64 / qemux86-64) Home Assistant Core: 2023.11.3 Home Assistant Supervisor: 2023.11.6 cat /etc/debian_version 11.8

I cannot figure out how to increase the logging to be of any help.

Here are the logs from starting from the addon...

s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-nginx: starting
s6-rc: info: service init-interface: starting
[00:45:37] INFO: Initialising NGINX
[00:45:37] INFO: Generating BACpypes.ini
s6-rc: warning: unable to start service init-nginx: command exited 1
[BACpypes]
objectName: enp0s31f6
address: 192.168.2.45/24
objectIdentifier: 420
maxApduLengthAccepted: 1476
segmentation: segmentedBoth
vendorIdentifier: 15
foreignBBMD: -
foreignTTL: 255
maxSegmentsAccepted: 64
loglevel: DEBUG
defaultPriority: 15
updateInterval: 60
s6-rc: info: service init-interface successfully started
s6-rc: info: service interface: starting
s6-rc: info: service interface successfully started
/run/s6/basedir/scripts/rc.init: warning: s6-rc failed to properly bring all the services up! Check your logs (in /run/uncaught-logs/current if you have in-container logging) for more information.
/run/s6/basedir/scripts/rc.init: fatal: stopping the container.
s6-rc: info: service interface: stopping
[00:45:38] INFO: Service BACnet Interface exited with code 256 (by signal 15)
s6-rc: info: service interface successfully stopped
s6-rc: info: service init-interface: stopping
s6-rc: info: service init-interface successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service base-addon-log-level: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service base-addon-log-level successfully stopped
s6-rc: info: service base-addon-banner: stopping
s6-rc: info: service base-addon-banner successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

More version info: Core 2023.11.3 Supervisor 2023.11.6 Frontend 20231030.2

Here is trying to start it manually

docker run -it ghcr.io/bepacom-raalte/amd64-bacnet-interface:1.1.3
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service base-addon-banner: starting
curl: (6) Could not resolve host: supervisor
[05:51:26] ERROR: Something went wrong contacting the API
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
curl: (6) Could not resolve host: supervisor
[05:51:26] ERROR: Something went wrong contacting the API
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-nginx: starting
s6-rc: info: service init-interface: starting
[05:51:26] INFO: Generating BACpypes.ini
[05:51:26] INFO: Initialising NGINX
s6-rc: info: service init-nginx successfully started
[BACpypes]
objectName: null
address: null/24
objectIdentifier: null
maxApduLengthAccepted: 1476
segmentation: segmentedBoth
vendorIdentifier: 15
foreignBBMD: -
foreignTTL: 255
maxSegmentsAccepted: 64
loglevel: null
defaultPriority: null
updateInterval: null
curl: (6) Could not resolve host: supervisor
[05:51:27] ERROR: Something went wrong contacting the API
s6-rc: info: service init-interface successfully started
s6-rc: info: service interface: starting
s6-rc: info: service interface successfully started
s6-rc: info: service nginx: starting
s6-rc: info: service nginx successfully started
s6-rc: info: service legacy-services: starting
[05:51:27] INFO: Running interface
s6-rc: info: service legacy-services successfully started
Traceback (most recent call last):
  File "/usr/bin/main.py", line 239, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/bin/main.py", line 161, in main
    logging.basicConfig(format="%(levelname)s:    %(message)s", level=loglevel)
  File "/usr/local/lib/python3.11/logging/__init__.py", line 2069, in basicConfig
    root.setLevel(level)
  File "/usr/local/lib/python3.11/logging/__init__.py", line 1464, in setLevel
    self.level = _checkLevel(level)
                 ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/logging/__init__.py", line 207, in _checkLevel
    raise ValueError("Unknown level: %r" % level)
ValueError: Unknown level: 'null'
[05:51:28] INFO: Service BACnet Interface exited with code 1 (by signal 0)
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service nginx: stopping
[05:51:28] INFO: Service NGINX exited with code 256 (by signal 15)
s6-rc: info: service nginx successfully stopped
s6-rc: info: service init-nginx: stopping
s6-rc: info: service interface: stopping
s6-rc: info: service interface successfully stopped
s6-rc: info: service init-interface: stopping
s6-rc: info: service init-interface successfully stopped
s6-rc: info: service init-nginx successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service base-addon-log-level: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service base-addon-log-level successfully stopped
s6-rc: info: service base-addon-banner: stopping
s6-rc: info: service base-addon-banner successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
Bepacom-Raalte commented 12 months ago

I haven't tested any recent version of the add-on on Home Assistant Supervised, so I don't know if it goes wrong there.

This is the script that's being run, so it's not a lot where it can go wrong. If you were to run the following in your terminal...

` readarray -t eth_adapters < <(ifconfig -a | grep -oE '^(enp|eth|eno|wl)[a-z0-9]+')

for adapter in "${eth_adapters[@]}"
do
    ipaddr=$(ifconfig "$adapter" | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
    if [ -n "$ipaddr" ]; then
        break
    fi
done

`

Would there be any faults in that? In init-interface there is a similar sort of script running, so I doubt there would be an issue in this part...

jaymemaurice commented 12 months ago

Well... ifconfig has been deprecated long ago... I had to manually install net tools in ubuntu and step through it, it doesn't work.

root@ha01:~# readarray -t eth_adapters < <(ifconfig -a | grep -oE '^(enp|eth|eno|wl)[a-z0-9]+')
root@ha01:~# echo $eth_adapters
enp0s31f6
root@ha01:~# for adapter in "${eth_adapters[@]}"
> do
>     ipaddr=$(ifconfig "$adapter" | grep 'inet addr' | cut -d: -f2 | awk '{print $1}'); echo $ipaddr
>     if [ -n "$ipaddr" ]; then
>         break
>     fi
> done

root@ha01:~# 
root@ha01:~# ifconfig "enp0s31f6"
enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 6c:4b:90:50:b1:7d  txqueuelen 1000  (Ethernet)
        RX packets 210345061  bytes 55969262234 (52.1 GiB)
        RX errors 0  dropped 263731  overruns 0  frame 0
        TX packets 149523968  bytes 28796360663 (26.8 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xf7200000-f7220000
root@ha01:~# ifconfig|grep -B 1 192\.168\.2
virbr1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.45  netmask 255.255.255.0  broadcast 192.168.2.255
--
wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.254.100  netmask 255.255.255.0  broadcast 192.168.254.255
root@ha01:~#

So it seems that on my home assistant supervised the virbr1 is my main interface. Not sure this is because I am also running KVM or if that's normal for supervised. If I modify your grep adding virbr... it still doesn't work the way you would expect it to since the grep for inet addr never matches.

root@ha01:~# ifconfig -a | grep -oE '^(enp|eth|eno|wl|virbr)[a-z0-9]+'
enp0s31f6
virbr1
wlp2s0
root@ha01:~# readarray -t eth_adapters < <(ifconfig -a | grep -oE '^(enp|eth|eno|wl|virbr)[a-z0-9]+'); echo $eth_adapters
enp0s31f6
root@ha01:~# readarray -t eth_adapters < <(ifconfig -a | grep -oE '^(enp|eth|eno|wl|virbr)[a-z0-9]+'); echo ${eth_adapters[1]}
virbr1
root@ha01:~# for adapter in "${eth_adapters[@]}"; do     ipaddr=$(ifconfig "$adapter" | grep 'inet addr' | cut -d: -f2 | awk '{print $1}');echo $ipaddr;     if [ -n "$ipaddr" ]; then         break;     fi; done

root@ha01:~# ifconfig virbr1|grep 'inet addr'
root@ha01:~# ifconfig virbr1
virbr1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.45  netmask 255.255.255.0  broadcast 192.168.2.255
        ether a2:5a:13:b7:61:ff  txqueuelen 1000  (Ethernet)
        RX packets 199724224  bytes 50312714626 (46.8 GiB)
        RX errors 0  dropped 273  overruns 0  frame 0
        TX packets 148624609  bytes 27973999783 (26.0 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0```
root@ha01:~# for adapter in "${eth_adapters[1]}"; do     ipaddr=$(ifconfig "$adapter" | grep 'inet' | cut -d: -f2 | awk '{print $2}');echo $ipaddr;     if [ -n "$ipaddr" ]; then         break;     fi; done
192.168.2.45

so ditching ifconfig which must be different on different hosts, the fixed command:

root@ha01:~# for adapter in "${eth_adapters[@]}"; do     ipaddr=$(ip addr show dev "$adapter" scope global| awk '/inet/{gsub(/\/.*/,"",$2); print $2}');echo $ipaddr;     if [ -n "$ipaddr" ]; then         break;     fi; done

192.168.2.45

I'm not sure what the point of all this is.... like why is it limiting the interface types?

Bepacom-Raalte commented 12 months ago

I'm not sure what the point of all this is.... like why is it limiting the interface types?

I've edited part of some code in init-interface to automatically find the LAN connection to the device with this. Most people don't like configuring their add-on or aren't tech savvy. It shouldn't automatically grab your wireless network or internal Home Assistant IP's. Ifconfig is installed with Home Assistant OS, so it generally isn't an issue.

What the purpose of this part is, is basically trying to get the IP it detected in the other service to make an exception in NGINX so it allows access from that IP address. Basically I could remove all security so it can be accessed from anywhere, but I don't think that's preferable.

What I'd like to do is change it so it makes a list of all local IP's and allows access to those. Something like ip_addresses=$(ip address show | grep 'inet ' | awk '{print $2}') should work for you as well then.

I am not proficient in Bash, so feel free to make suggestions! Surely, we can make it work eventually.

jaymemaurice commented 12 months ago

try hostname -I

root@ha01:~# hostname -I
192.168.254.100 192.168.2.45 172.17.0.1 172.30.32.1

and if you want to use | grep "something" | awk "{}" try | awk '/something/{}' instead and save your forks for a cake

Bepacom-Raalte commented 12 months ago

and if you want to use | grep "something" | awk "{}" try | awk '/something/{}' instead and save your forks for a cake

Feel free to keep the sass at home. hostname -I doesn't work om HA OS, so it's not an option. I'll take a look at it next week.

jaymemaurice commented 12 months ago

But I’m selling t-shirts here:) Thanks for all the work you do.

On Fri, Dec 8, 2023 at 10:49 AM Bepacom B.V. Raalte < @.***> wrote:

and if you want to use | grep "something" | awk "{}" try | awk '/something/{}' instead and save your forks for a cake

Feel free to keep the sass at home. hostname -I doesn't work om HA OS, so it's not an option. I'll take a look at it next week.

— Reply to this email directly, view it on GitHub https://github.com/Bepacom-Raalte/bepacom-HA-Addons/issues/29#issuecomment-1847416305, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJIX5V7DNHPFKTYTK3AGX33YIMZI7AVCNFSM6AAAAABAMFCRSGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBXGQYTMMZQGU . You are receiving this because you authored the thread.Message ID: @.***>

Bepacom-Raalte commented 11 months ago

Try the latest dev version, see if it works now.

jaymemaurice commented 11 months ago

It started!

I'll let you know how I get on with it. I am currently using node red in my house to bridge the delta bas to my home assistant. I am interested in this addon for CoV subscription instead of the tight polling I am currently doing.

On Mon, Dec 11, 2023 at 1:51 AM Bepacom B.V. Raalte < @.***> wrote:

Try the latest dev version, see if it works now.

— Reply to this email directly, view it on GitHub https://github.com/Bepacom-Raalte/bepacom-HA-Addons/issues/29#issuecomment-1849426595, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJIX5V5YHCMZYDWDLO73UX3YI2UQBAVCNFSM6AAAAABAMFCRSGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBZGQZDMNJZGU . You are receiving this because you authored the thread.Message ID: @.***>

Bepacom-Raalte commented 11 months ago

Great to hear! Let me know if there are any more issues.