Local Mode not working

Ah, those error messages may be OK, :slight_smile: if they stop happening after “Device state settled” is printed. What may be happening (admittedly confusing) is that log messages printed by the “current” running container (which will be replaced by balena push) are mixed with balena push output for ongoing events…

Line by line:

[Logs] [2020-4-10 17:05:31] Restarting service ‘main ...

This means that balena-cli has started the procedure of restarting the current container…

[Logs] [2020-4-10 17:05:10] [main] Error: Expecting value: line 1 column 1 (char 0)

This line may still be output from the current/old container which was in a failure restart loop…

[Logs] [2020-4-10 17:05:35] Killing service ‘main ...

balena-cli will now attempt to kill (stop and remove) the current/old container…

[Logs] [2020-4-10 17:05:41] [main] Error: Expecting value: line 1 column 1 (char 0)

Still possibly output from the current/old container before it is killed…

[Logs] [2020-4-10 17:05:51] Service exited ‘main ...
[Logs] [2020-4-10 17:05:51] Killed service ‘main ...

Now the old container ought to stop printing errors…

[Logs] [2020-4-10 17:05:57] Installing service ‘main ...
[Logs] [2020-4-10 17:05:58] Installed service ‘main ...
[Logs] [2020-4-10 17:05:58] Starting service ‘main ...
[Logs] [2020-4-10 17:06:07] Started service ‘main ...

Now log messages should refer to the “new” container.

@pdcastro I deleted the container so that I was starting afresh and tried to run with the parameters set up in the config.json file. I didn’t like seeing syntax and compile errors:

PS C:\balena\train-display> balena push 192.168.1.24 --convert-eol
[Info] Starting build on device 192.168.1.24
[Info] No “docker-compose.yml” file found at “.”
[Info] Creating default composition with source: “.”
[Build] [main] Step 1/12 : FROM balenalib/raspberry-pi-debian-python:3.7-buster-build
[Build] [main] —> 31b9693234ae
[Build] [main] Step 2/12 : RUN install_packages jq moreutils libopenjp2-7 libfreetype6-dev libjpeg-dev libtiff5
[Build] [main] —> Using cache
[Build] [main] —> 2c510d2236f7
[Build] [main] Step 3/12 : WORKDIR /usr/app
[Build] [main] —> Using cache
[Build] [main] —> 7a11ca2159db
[Build] [main] Step 4/12 : COPY ./requirements.txt .
[Build] [main] —> Using cache
[Build] [main] —> e84bf2914361
[Build] [main] Step 5/12 : RUN pip install -r requirements.txt
[Build] [main] —> Using cache
[Build] [main] —> 1cddab77a12f
[Build] [main] Step 6/12 : COPY src ./src
[Build] [main] —> Using cache
[Build] [main] —> 3d9067e40d64
[Build] [main] Step 7/12 : COPY balena-run.sh ./
[Build] [main] —> Using cache
[Build] [main] —> eba067074893
[Build] [main] Step 8/12 : COPY config.sample.json ./
[Build] [main] —> Using cache
[Build] [main] —> cba3267718f9
[Build] [main] Step 9/12 : RUN chmod +x balena-run.sh
[Build] [main] —> Using cache
[Build] [main] —> 9ac1567db877
[Build] [main] Step 10/12 : CMD ./balena-run.sh
[Build] [main] —> Using cache
[Build] [main] —> ab597b7e98c3
[Build] [main] Step 11/12 : LABEL io.resin.local.image=1
[Build] [main] —> Using cache
[Build] [main] —> 9147891c06a4
[Build] [main] Step 12/12 : LABEL io.resin.local.service=main
[Build] [main] —> Using cache
[Build] [main] —> 6ba2255341e5
[Build] [main] Successfully built 6ba2255341e5
[Build] [main] Successfully tagged local_image_main:latest

[Live] Waiting for device state to settle…
[Info] Streaming device logs…
[Live] Watching for file changes…
[Logs] [2020-4-10 21:24:59] Installing service ‘main sha256:6ba2255341e528d519fed7a298c46eadee6eb5b029468fee105c7a1b82c7743b’
[Logs] [2020-4-10 21:25:01] Installed service ‘main sha256:6ba2255341e528d519fed7a298c46eadee6eb5b029468fee105c7a1b82c7743b’
[Logs] [2020-4-10 21:25:01] Starting service ‘main sha256:6ba2255341e528d519fed7a298c46eadee6eb5b029468fee105c7a1b82c7743b’
[Logs] [2020-4-10 21:25:11] Started service ‘main sha256:6ba2255341e528d519fed7a298c46eadee6eb5b029468fee105c7a1b82c7743b’
[Logs] [2020-4-10 21:25:07] [main] jq: error: syntax error, unexpected $end (Unix shell quoting issues?) at , line 1:
[Logs] [2020-4-10 21:25:07] [main] .refreshTime=
[Logs] [2020-4-10 21:25:07] [main] jq: 1 compile error
[Live] Device state settled
[Logs] [2020-4-10 21:25:21] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-10 21:25:28] Service exited ‘main sha256:6ba2255341e528d519fed7a298c46eadee6eb5b029468fee105c7a1b82c7743b’
[Logs] [2020-4-10 21:25:38] Restarting service ‘main sha256:6ba2255341e528d519fed7a298c46eadee6eb5b029468fee105c7a1b82c7743b’
[Logs] [2020-4-10 21:25:21] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-10 21:25:41] [main] Error: Expecting value: line 1 column 1 (char 0)

Hi @Nigel,

Just a quick check, because the config.json is being used instead now it looks like the line endings in it are not being converted, which is why jq complains about it here:

[Logs] [2020-4-10 21:25:07] [main] jq: error: syntax error, unexpected $end (Unix shell quoting issues?) at , line 1:
[Logs] [2020-4-10 21:25:07] [main] .refreshTime=
[Logs] [2020-4-10 21:25:07] [main] jq: 1 compile error

My assumption is that for some reason this file is not getting converted, I’m going to ping Paulo again just to confirm that every source/data file should be being converted, but for the meantime you may need to run a Windows to Unix line ending utility over the config.json and then retry. Could you let us know if that does solve the problem, as then it would point to balena CLI not doing this.

Many thanks,

Heds

Hi @hedss I checked the config.json file and it has Unix line endings:

config_json

Hi @Nigel,

Yep, that absolutely looks like it should work to me! What’s also confusing having looked a bit more is that it’s complaining about line 1 for “refreshTime=” and yet in your config, that’s on about the 9th line. This seems extremely strange to me, as if the wrong config is being pulled in. There’s no other duplicate configs being pulled in, are their, or incorrect files being referenced in the Dockerfile?

Best regards,

Heds

@Nigel, I have tested using a config.json file and I got the jq error as well, same as you. It is not a CRLF / EOL issue – I actually tested with CRLF line endings too, and the --convert-eol option does its job just fine. Debugging it further, I found that the repo’s .gitignore file has a line listing “config.json”. I edited the .gitignore file, deleted the line that listed config.json, and then it worked. Actually, you could delete the .gitignore file altogether, at:

C:\balena\train-display\.gitignore

I am not sure whether this is a “project bug” and config.json should not have been listed in the .gitignore file, or whether it was my mistake to advise you to use the config.json file in the first place - I’ve asked the project maintainer for his view, and created a GitHub issue on the project repo.

So, deleting the .gitignore file might do the trick for now. (In case you wonder: the CLI looks at both the .gitignore and .dockerignore files to decide what to push to devices or to the cloud. There are plans to change this so the CLI stops looking at the .gitignore file, but currently it takes both ignore files into account.)

Otherwise:

  • The following also worked for me (or at least it avoided the jq error for refreshTime, and of course I am using my own IP address…):
balena push 192.168.1.24 --env departureStation="NBY" --env transportApi_apiKey="377..." --env transportApi_appId="ebb..." --env transportApi_operatingHours="7-23" --env outOfHoursName="Newbury" --env refreshTime=180 --convert-eol
  • If you still come across further such errors, try adding the echo and print lines that I mentioned in a previous message, to isolate where the issue is.

@pdcastro I deleted the .gitignore file and added the suggested debug print statements:

PS C:\balena\train-display> balena push 192.168.1.24 --convert-eol
[Info] Starting build on device 192.168.1.24
[Info] No “docker-compose.yml” file found at “.”
[Info] Creating default composition with source: “.”
[Build] [main] Step 1/12 : FROM balenalib/raspberry-pi-debian-python:3.7-buster-build
[Build] [main] —> 31b9693234ae
[Build] [main] Step 2/12 : RUN install_packages jq moreutils libopenjp2-7 libfreetype6-dev libjpeg-dev libtiff5
[Build] [main] —> Using cache
[Build] [main] —> 2c510d2236f7
[Build] [main] Step 3/12 : WORKDIR /usr/app
[Build] [main] —> Using cache
[Build] [main] —> 7a11ca2159db
[Build] [main] Step 4/12 : COPY ./requirements.txt .
[Build] [main] —> Using cache
[Build] [main] —> e84bf2914361
[Build] [main] Step 5/12 : RUN pip install -r requirements.txt
[Build] [main] —> Using cache
[Build] [main] —> 1cddab77a12f
[Build] [main] Step 6/12 : COPY src ./src
[Build] [main] —> 2a8ceab41ebd
[Build] [main] Step 7/12 : COPY balena-run.sh ./
[Build] [main] —> 5d82ef08573f
[Build] [main] Step 8/12 : COPY config.sample.json ./
[Build] [main] —> 330338becaa1
[Build] [main] Step 9/12 : RUN chmod +x balena-run.sh
[Build] [main] —> Running in 1043f307f1da
[Build] [main] Removing intermediate container 1043f307f1da
[Build] [main] —> 4c550d55c167
[Build] [main] Step 10/12 : CMD ./balena-run.sh
[Build] [main] —> Running in 7195ee5ae3e3
[Build] [main] Removing intermediate container 7195ee5ae3e3
[Build] [main] —> 8204d72c873f
[Build] [main] Step 11/12 : LABEL io.resin.local.image=1
[Build] [main] —> Running in 320544a7611a
[Build] [main] Removing intermediate container 320544a7611a
[Build] [main] —> c92d875226b3
[Build] [main] Step 12/12 : LABEL io.resin.local.service=main
[Build] [main] —> Running in 916d61ec8e28
[Build] [main] Removing intermediate container 916d61ec8e28
[Build] [main] —> edaf60b659c8
[Build] [main] Successfully built edaf60b659c8
[Build] [main] Successfully tagged local_image_main:latest

[Live] Waiting for device state to settle…
[Info] Streaming device logs…
[Live] Watching for file changes…
[Logs] [2020-4-11 14:26:17] Installing service ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:26:18] Installed service ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:26:18] Starting service ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:26:28] Started service ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:26:25] [main] entering balena-run.sh …
[Logs] [2020-4-11 14:26:26] [main] jq: error: syntax error, unexpected $end (Unix shell quoting issues?) at , line 1:
[Logs] [2020-4-11 14:26:26] [main] jq: 1 compile error
[Logs] [2020-4-11 14:26:26] [main] got past if statement…
[Logs] [2020-4-11 14:26:26] [main] .refreshTime=
[Logs] [2020-4-11 14:26:39] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-11 14:26:39] [main] about to load the config.json file…
[Live] Device state settled
[Logs] [2020-4-11 14:26:45] Service exited ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:26:55] Restarting service ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:26:39] [main] about to load the config.json file…
[Logs] [2020-4-11 14:26:52] [main] got past if statement…
[Logs] [2020-4-11 14:26:52] [main] entering balena-run.sh …
[Logs] [2020-4-11 14:26:39] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-11 14:27:02] [main] about to load the config.json file…
[Logs] [2020-4-11 14:27:02] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-11 14:27:10] Service exited ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:27:42] Restarting service ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:27:02] [main] about to load the config.json file…
[Logs] [2020-4-11 14:27:02] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-11 14:27:33] [main] entering balena-run.sh …
[Logs] [2020-4-11 14:27:33] [main] got past if statement…
[Logs] [2020-4-11 14:27:47] [main] about to load the config.json file…
[Logs] [2020-4-11 14:27:47] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-11 14:27:53] Service exited ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:28:03] Restarting service ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:27:47] [main] about to load the config.json file…
[Logs] [2020-4-11 14:27:47] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-11 14:28:00] [main] entering balena-run.sh …
[Logs] [2020-4-11 14:28:00] [main] got past if statement…
[Logs] [2020-4-11 14:28:09] [main] about to load the config.json file…
[Logs] [2020-4-11 14:28:09] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-11 14:28:14] Service exited ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:28:23] Restarting service ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:28:09] [main] about to load the config.json file…
[Logs] [2020-4-11 14:28:09] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-11 14:28:20] [main] entering balena-run.sh …
[Logs] [2020-4-11 14:28:21] [main] got past if statement…
[Logs] [2020-4-11 14:28:29] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-11 14:28:29] [main] about to load the config.json file…
[Logs] [2020-4-11 14:28:33] Service exited ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:28:43] Restarting service ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’
[Logs] [2020-4-11 14:28:40] [main] entering balena-run.sh …
[Logs] [2020-4-11 14:28:40] [main] got past if statement…
[Logs] [2020-4-11 14:28:29] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-11 14:28:29] [main] about to load the config.json file…
[Logs] [2020-4-11 14:28:48] [main] about to load the config.json file…
[Logs] [2020-4-11 14:28:48] [main] Error: Expecting value: line 1 column 1 (char 0)
[Logs] [2020-4-11 14:28:54] Service exited ‘main sha256:edaf60b659c8fe424dfab4d699665f12128189d7f6c048314a2f0dcbf8baf5df’

I deleted the .gitignore file and added the suggested debug print statements:

@Nigel, sorry, besides deleting the .gitignore file, there was another change that I had made for my “successful test”, which I forgot to mention. I had also edited the Dockerfile.template file to replace the following line:

   
Before: COPY config.sample.json ./
After: COPY config*.json ./

I’ve asked the project maintainer for his view, and created a GitHub issue on the project repo.

He replied, explaining he had always used the long command line with the --env arguments, instead of using a config.json file. The logic coded in the balena-run.sh script had not been tested with a config.json file, hence the issues with the .gitignore and Dockerfile.template files. So it looks like using the config.json file is to walk off the beaten path, and if you continue to experience issues, you may prefer to go back to the long command line with --env arguments.

@pdcastro, OK, it works with the --env arguments passed in the command line. What a joy to see it run with no errors! Now I have a stable refence, I can procede. Thanks for staying with me with this problem.

No problem, glad to hear you got it working! :+1:

@Nigel in case it’s of interest to you there were some improvements to the project to make local development smoother https://github.com/balenalabs/uk-train-departure-display/pull/19

this includes the issue with config.json