Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built locally addon fails to start #14

Closed
james-fry opened this issue May 22, 2018 · 11 comments
Closed

Built locally addon fails to start #14

james-fry opened this issue May 22, 2018 · 11 comments

Comments

@james-fry
Copy link

I want to build the addon locally so that I can use my fork of zigbee2mqtt when testing for new devices.

In order to achieve this I did the following:

  1. Cloned this hassio-zigbee2mqtt repo
  2. Created a new dir \hassio\addons\zigbee2mqtt
  3. Copied the four files from hassio-zigbee2mqtt/zigbee2mqtt (config.json, dockerfile, run.sh and set_config.py) to the dir \hassio\addons\zigbee2mqtt
  4. Removed the image statement from config.json
  5. Installed the addon from my local repo. It builds locally. When this happens I can see (via portainer) that a new docker image is created and is same size as the image pulled from your dockerhub
  6. Start the addon...

I get an error:

[FATAL tini (5)] exec /app/run.sh failed: No such file or directory

In portainer I compared the image layers and it seems that the two images - yours from docker hub and mine built locally - are identical with the exception of tags...

really odd.

@danielwelch
Copy link
Owner

This is an odd one. I've tested building locally both on my raspberry pi 3 running hassio and with a hassio vagrant box, and haven't run into this issue. I'll keep looking into it, but can't reproduce it locally. Does this happen with other add-ons you've built locally?

@ciotlosm
Copy link
Collaborator

ciotlosm commented May 23, 2018

Later edit: I think I had the version before the last commit to set_config.py. It is now working on the Orange Pi. I will now look into pm2
.
I was able to reproduce startup errors with the latest build. I had to dig a lot to fix basic starting problems on my new orange pi (see home-assistant/supervisor#477) but It was really annoying to build locally on a rpi1 :-)

The errors I see so far - that I will try to patch today:

Traceback (most recent call last):
  File "/data/options.json", line 3, in <module>
    "homeassistant": true,
NameError: name 'true' is not defined

> zigbee2mqtt@0.1.0 start /app
> node index.js

fs.js:646
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/share/zigbee2mqtt/configuration.yaml'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at read (/app/lib/util/settings.js:32:24)
    at Object.<anonymous> (/app/lib/util/settings.js:7:12)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! zigbee2mqtt@0.1.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the zigbee2mqtt@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-05-22T20_04_11_944Z-debug.log

@ciotlosm
Copy link
Collaborator

ciotlosm commented May 23, 2018

@james-fry maybe when you copied the files don't have correct permissions and the entry point script didn't get into your container.

You could try docker exec -it <your_local_container_name> /bin/bash and then explore a bit what's inside the /app

Also make sure you have the latest changes from the repo.

@ciotlosm
Copy link
Collaborator

It doesn't build locally now on my Orange Pi

18-05-23 17:32:02 ERROR (SyncWorker_14) [hassio.docker.addon] Can't build local/aarch64-addon-zigbee2mqtt:1.0: The command '/bin/sh -c apk add --update --no-cache jq nodejs nodejs-npm python3 python3-dev         python2 make gcc g++ linux-headers udev git &&         pip3 install PyYAML &&         git clone -b master --single-branch --depth 1 https://github.com/Koenkk/zigbee2mqtt.git /app' returned a non-zero code: 159

@danielwelch
Copy link
Owner

@ciotlosm Can't replicate that. That's an issue at the Dockerfile / container creation level, which hasn't changed in over a week. Is the 159 error code indicative of running out of resources?

@ciotlosm
Copy link
Collaborator

ciotlosm commented May 23, 2018

@danielwelch I never tried to build on generic linux or orange pi. Previously I had a RPI1 which was killing me at how slow it was doing things, so this is a new setup. I don't know what to try to fix it.

It seems even a simple command like 18-05-23 17:47:07 ERROR (SyncWorker_17) [hassio.docker.addon] Can't build local/aarch64-addon-zigbee2mqtt:1.0: The command '/bin/sh -c apk update' returned a non-zero code: 159 fails

I think it has something to do with apk and what it's being used as BUILD_FROM

@danielwelch
Copy link
Owner

I've successfully built locally on Raspberry pi 3 as well as virtualbox linux, and of course the travis build is successful if the Docker image is built successfully (which is your problem here). Wouldn't think it'd be a resources issue if you didn't have this problem on Rpi1 but are having it now with new hardware.

@ciotlosm
Copy link
Collaborator

ciotlosm commented May 23, 2018

Let me try on RPI3 (production) with same setup to eliminate human error on my side :-)

Update: On the RPI3 it builds, so it must be a build dependency not specified that it's missing on the host OS for Orange Pi

@ciotlosm
Copy link
Collaborator

@danielwelch Found the problem I think. It's the same stupid seccomp. I removed it from addon start, but not from addon build. I'll have to patch the supervisor again ....

@james-fry
Copy link
Author

james-fry commented May 23, 2018

@danielwelch

Does this happen with other add-ons you've built locally?

No - all working well

@ciotlosm

You could try docker exec -it <your_local_container_name> /bin/bash and then explore a bit what's inside the /app

Its not so easy since the container quits as soon as it starts due to the issue with the CMD. You can only attach to a running container...

So I ran:

docker export addon_local_zigbee2mqtt_jf > addon_local_zigbee2mqtt_jf.tar

then explored the image fs in the resulting tar.
I can see nothing wrong with the image... the /app dir has run.sh and set_config.py present.
run.sh is executable (+x)

I'm going to try it again from scratch... but I am pretty sure I will see the same.

@james-fry
Copy link
Author

james-fry commented May 23, 2018

OK started this again.

  1. Deleted all zigbee2mqtt addons
  2. Deleted any related images
  3. Downloaded the zip from GH
  4. Extracted the zigbee2mqtt folder to hassio addons
  5. Edited config.json to remove image
  6. Installed the local addon to trigger build.

Build log from hassio supervisor:

18-05-23 21:37:01 INFO (MainThread) [hassio.addons.addon] Create Home-Assistant addon data folder /data/addons/data/local_zigbee2mqtt
18-05-23 21:37:01 INFO (SyncWorker_4) [hassio.docker.addon] Start build local/amd64-addon-zigbee2mqtt:test
18-05-23 21:38:32 INFO (SyncWorker_4) [hassio.docker.addon] Build local/amd64-addon-zigbee2mqtt:test done

... and it works!
😄

Dunno what when wrong before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants