UniversalDevicesInc/Polyglot

Interrupted polyglot now have zero size config file.

Closed this issue · 13 comments

I control-C'ed Polyglot, then when I tried to start it again I got json errors, which I traced down to an empty config file. My guess is that it was writing the config when I interrupted?

pi@rpi2:~/dev/Polyglot $ ls -l config/configuration.json
-rw------- 1 pi pi 0 Mar 12 16:50 config/configuration.json

This problem was noted earlier on the forum by someone - so it would seem that it's more probable than it seems at first glance at the code. I suspect buffering may be making it more likely to happen -- but the fix is to write to a temp file, then use rename (mv) operations, which are atomic and thus won't leave us without a valid config file.

Also, the code should check to see if its really necessary to rewrite the config file in the first place - it's almost always going to be identical to the one on-disk. Excessive writes will wear out an SD card on the RPi.

I'm going to work on some of this stuff today. Has anyone started work on this yet? I'll take it on today if not.

I've not looked at it yet. Thanks!

On Sun, Mar 13, 2016, 8:10 AM James notifications@github.com wrote:

I'm going to work on some of this stuff today. Has anyone started work on
this yet? I'll take it on today if not.


Reply to this email directly or view it on GitHub
#6 (comment)
.

Also, I think it happened to me because I hit control c twice in a row. Which interrupted the write it tries to do before exiting from trapping the first signal.

No problem. I'll work on something.

Updated this with latest pull request. Please verify and merge.

I'm not sure if my issue was caused by this change, but now every time I kill and restart polyglot I lose my configuration? I kill polyglot, check my configuration.json and all node servers are still there, then I start polyglot again and the node servers are not in the configuration.json anymore? It still has the correct ISY ip address and password, so I'm not loosing all configuration, just the node servers. Can you verify this is not an issue for you?

What I'm seeing in my installation are the same symptoms -- the node servers all go away on restart. The problem does not seem to be that the config file is damaged on shutdown -- the file is complete whenever I check. The problem is that the configuration is damaged on startup. So something has changed with the logic there that has resulted in the node servers portion of the configuration to become empty (all else is the same in the data written to the config file).

Interesting. I will investigate.

On Sun, Mar 20, 2016 at 7:17 PM, Mike Westerhof notifications@github.com
wrote:

What I'm seeing in my installation are the same symptoms -- the node
servers all go away on restart. The problem does not seem to be that the
config file is damaged on shutdown -- the file is complete whenever I
check. The problem is that the configuration is damaged on startup. So
something has changed with the logic there that has resulted in the node
servers portion of the configuration to become empty (all else is the same
in the data written to the config file).


You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub
#6 (comment)

I backed down to commit 1eca521 (the last one committed by Einstein42 regarding to this issue) -- works fine. So I suspect that it is more recent -- I'm suspicious of the changes made to nodeserver_api.py -- but I cannot bisect this any further because the node restructuring code is not working from the first commit on this branch up to the last couple... :(

I'll update the issue for the for the internal node structure with this info too.

The second change in this commit seemed a little suspicous 839351d It specifically moved the nodeservers.load

Looks like a different change caused the issue.

Jim you are correct, simply put the cart before the horse on the update config. I've tested with the HUE and restarted 10 times in a row and had the hue poly start every time with no errors. Control-c'd repeatedly and tried to break it. All successful. Merging to development