Catalyst, nginx and FastCGI – my first bloody nose
Always a glutton for punishment, a recent project to redevelop a website involved changing pretty much every layer of the stack – Apache became nginx, mod_perl became FastCGI, and the custom code was moved into a Catalyst project. Having never seriously worked with any of these before, my first deployment (today!) was an interesting affair.
Note: This deployment is only to a staging area, so I’ve still got time to correct the worst of my mistakes. 🙂
Catalyst was (mostly) fine. The purists will probably scream, but I found that all I really needed was the ‘lib’, ‘root’ and ‘script’ directories copied up, along with the config file. I’m intending to put the site(s) into .deb packages for ease of deployment (is that more screaming I hear?) so keeping it simple works for me.
nginx was also pretty easy. I spent a bit of time on the search engines reading how everyone else is doing it, and pretty soon I had lovely Catalyst error messages coming up – better than “502 Bad Gateway”, at least. Getting nginx to serve the appropriate directories from ‘root’ was simple enough, so the simple static content server in Catalyst wasn’t needed any more.
The biggest snag I hit was getting the project to run as a FastCGI server. The Catalyst script seemed to start it up without any complaints, but it wasn’t reading my config file. Eventually, I found that copying the config file into the main lib/$projectname directory worked – not obvious, and probably not the right way of doing it, but once again – it works for me.
I’ve still got a fair amount of work to do before I can go live with this project – not least of all fixing the custom C::P::Session::State component I created – but so far I’ve had a couple of people run across the site and it all seems to work (well, no obvious errors at least). I just need to find some way of having different dev/live configurations (like turning off debug and Static::Simple) and the “correct” way of getting the config file loaded without moving it around and then I’ll be happy.
All in all, though, given that the site I’m recreating was developed over the course of a year (evolutionary model, pretty much) and was moved into the Catalyst framework within two months (only seriously for one of them), I’m pretty impressed with the speed at which things can be developed. The real test, however, will be how it performs when it goes live – given that this site gets (according to Google Analytics) some 200,000 page views per day, it’s going to be an interesting experience all round…