I recently completed some much needed upgrades to the servers (hardware and software) that run Stonelinks. This has me very excited and has been a long time in the works! Warning: long and somewhat pointless story of blood, sweat, nerdrage and glorious payoff ahead.
These two suckers now live on my desk and throw off a ton of heat.
Despite being a humongous Linux nerd, for years I have hosted Stonelinks using Windows / WAMP server (which is the same thing as LAMP, just replace Linux with Windows). For a long time this was my only option as far as “free” hosting using RPI’s bandwidth, as my desktop is the only computer I own that is consistently on 24/7 and can function in a server role.
By necessity, my desktop needs to be running Windows 7 because unfortunately I need access to a bunch of programs that I can’t get or don’t exist for Linux. Things like LabVIEW for work at the Harvard-Smithsonain Center for Astrophysics, MATLAB so my room mate can run his week-long computational fluid dynamic simulations on for his research (we need our own supercomputer for this!), Solidworks for random CAD I occasionally do, Netflix because content licensing people are afraid of Linux and finally Team Fortress 2 because I occasionally like to get my game on. Because of the sporadic nature of when I use most of these programs, it also means that dual booting between Linux and Windows is of the question since that doesn’t guarantee uptime. I didn’t want to shut down the server while someone was using it just so I could boot into Windows and do some CAD.
Therefore, I have stuck with my WAMP setup for many years. As far as WAMP is concerned, it has sort of been “fine” most of the time, but definitely not ideal. All of the other websites I work on are hosted from some flavor of Linux. It is free, extremely stable, makes administration and development a breeze compared to Windows (what a nightmare it was to get PHP’s
mail() command to work with SSL in Windows), the list goes on.
Hosting Stonelinks under Linux has been a goal/dream of mine for awhile now. Occasionally I would try using a virtual machine to host, but I’d always find that to be too resource intensive and would BSOD windows after awhile if left on for too long. Cygwin was and always has been a nightmare for me too, so I didn’t even go there. Interestingly, I did have some success with something called andLinux which, by my understanding, is an Ubuntu installation based around a Linux kernel compiled to use win32 system calls a la coLinux. All the benefits of a virtual machine without the instability and losing a massive chunk of RAM. I ultimately dumped andLinux, mostly because andLinux uses a virtual network adapter to communicate with Windows. A webserver running under andLinux would be heavily bandwidth constrained for any clients other than localhost. So up until writing this I’ve been really, throughly stuck.
Fast forward to a few weeks before Christmas. For an early Christmas present, I decided to replace my Dad’s aging Dell with a Newegg special custom desktop. I built him a pretty sweet machine, and even got him using Ubuntu (quite the tech-savvy 63 year old!), with a Windows XP virtual machine to fall back on if he ever gets really stuck with something. This left his old desktop vacated for me to use!
The Dell made it’s glorious pilgrimage to RPI with me where I proceeded to wipe it’s brains and installed the latest Ubuntu on it. I then began the task of porting Stonelinks over to that machine. One problem though: my Dad’s old Dell did not have enough disk space for it.
Queue my second Newegg purchase: I bought two 2-TB SATA disks and a RAID card (among other things) on cyber Monday for the crazy price of $180 (granted the RAID card is not a “real” RAID card, as none of the parity checking for RAID is done by hardware on the card it is basically a glorified SATA controller). I wrongfully assumed that since the RAID card was PCI, it would be compatible with the old Dell. I thought that since there were no SATA ports on the motherboard of the Dell I could use the RAID card to be the root of the webserver. At the very worst, I knew the firmware on the card was swappable so I could re-flash firmware on the card to make it act as a pass through (no RAID whatsoever) for the drives to the OS. Booooy was I wrong.
First of all, the RAID controller was not being picked up, not even in the BIOS, on the Dell. No matter what I tried, it wouldn’t work in the Dell (and yes I had the Linux drivers for it / proper kernel modules running). I thought I might have a defective card so I tried it in a spare PCI slot on my desktop. The card worked like a charm! At this point I was tearing my hair out – Something on the Dell’s motherboard was incompatible with the RAID card? I didn’t even care about RAID at this point, I just wanted SATA drives to work on the Dell at which point I could use something like mdadm for fake RAID. I thought that flashing the firmware that makes the card act like a pass through was a good idea. This opened up a new can of nightmares for me!
Turns out that Silicon Image (SI from here on out), the maker of the “fake” RAID controller chip on the card I bought, supplies its chips / firmware to 3rd parties that put together the cards and sell them. In order to even begin messing with the firmware on the card I had to use a bunch of really bad DOS executables that I called from the command line, and then had to echo the return value (took me forever to figure out how to do… damn windows shell) so I could match the number up with the response code on some PDF off their website and figure out what was wrong. At this point I am furious that I’ve wasted so much time on this. Using the sinfully awful SI tools, I eventually figured out that my card manufacturer, Rosewill, was storing the device firmware on an external flash chip that I could not flash with any different firmware.
At this point I have not slept in probably 24 hours and am feeling like I want to skewer the card on my African war sword (yes I own one of these) throw it in the oven, set it to self clean and walk away. Alas, I am too stubborn to give up like that though, so I cook up what became my final solution to hosting this iteration of Stonelinks.
Essentially, I separated content between the two servers by keeping the RAID array on my main desktop, sharing it as a Windows share, and then using autofs to mount the share on the Dell / Ubuntu and serve it. Both machines live behind the same 10/100 switch and I can pull data off there at fairly high speeds, so I was happy! The hardest part about getting this to work was managing permissions between the two machines and finding a good way to keep track of my Desktop because its IP was no longer static. I accomplished the former by being a clever chmod user, and the latter with dynamic DNS. Overall, I’d say the lessons I learned from this were things I already knew but were or sure reinforced:
Ever wanted to use google imagery inside of a leaflet map? This is just a small example of a google maps imagery / base layers hosted inside of a leaflet map. Check out where the magic happens on github: here.
Written by Lucas Doyle, a robotics engineer who does a lot of web development in San Francisco.