The init hook enigma, part 2

I struggled a few days with some functionality on the new CarChannel site where visitors are offered a splash page the first time they visit the site. I needed to built in some exceptions, like the special msn page, the xml calls and the game pages. Testing when you are logged in always worked, but when browsing anonymous and with normal caching on, things went wrong, especially with url aliases. Reading source code and documentation - or now when you are reading this article - can save your life, so when you have an init hook and you need the know the 'q' variable, add

drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);

at the top of your hook before doing anything else. This will save you many sleepless hours and frustrating tests!

Being the only *nix sysadmin (or at least, the only guy at work who knows a little more then just opening an ssh-session) also made me very stressed out the last couple of weeks because services suddenly died without leaving any information in logs. I spent the whole afternoon yesterday setting up extra monitoring services on 2 higly imported webservers which check apache, mysql, ssh and load average every five minutes and , if needed, takes the appropriate action (restart, renice etc). It was the first night in a week I finally slept the whole night through, so fingers crossed!

You are here