Tuesday, December 11, 2012

Server reboot

After 465 days, or one leap year and 99 days, the home automation server rebooted!
 
Not that it wasn't going strong, just the painter/handyman that came around to fix some things disconnected the power, causing the reboot!
 
I still find it impressive that it ran so long with no issues.
 
However, upon the reboot a few problems came to light, mainly due to my lack of knowledge and of proper planning.
 
The little executables that I have written to listen to the arduino that reads the meters, and the JeeLink that a talks to the boiler did not get started upon rebooting of the server, which is not ideal, considering the winter is here to stay. To make matters worse, this happened on a Tuesday, and on Wednesday I was traveling to Berlin for work. If he did it again during my absence, it would not be nice for the rest of the family.
So first, when I got home, I restarted the whole stuff, so that the house would come back to a decent temperature. This already revealed a little bit of the problem, which is that a certain device not always gets the same device driver in Linux. So that was the first problem to tackle, quickly solved with some rules in udev to create an aptly named file under /dev based on the serial number of the device. Only possibility, since both the arduino and the JeeLink both share the same identification information.
Next was to start these executables automatically. I had tried before to put them in init.d, but that had not worked. So, after many reboots to try different configurations, I finally found out that, since my programs are not properly written to be daemons, they never return, and then init.d does not launch them.

The solution came with 'startproc' which launches any executable as a daemon! Put that in the corresponding init.d configuration file and off it goes!

Another reboot to check that all is well, and time to bed!

Did not receive any complaints while in Berlin, so all was good!

I really should use better technologies to get these things going, but I always find that once it is working, it is difficult to motivate myself to improve it! I always move quickly onwards to the next problem...

As a further note, this server, a mini-itx board, has been running the house for 5 years now! I ordered a raspberry-pi to replace it, just due to the power consumption. I now have around 25W, and I hope the Pi will do with at most 10W!