Posting in June for work done in May I am the bane of this sites hopes to keep all the projects in tune with their month, sorry about that. Meanwhile what I had hoped to be playing with , namely near realtime ajax and site interactivity took a back seat as a seperate learning experience came up.
Catalyst is a Perl MVC Framework and has been used for numerous web projects and applications all of which are now starting to feel a little bit legacy thanks to Rails and Node.js. However support in terms of system administration is still required as a result I had the opportunity of taking on the hosting and uptime for a previous Catalyst application and this meant my rather straight forward appreciation of Apache Mysql and PHP would have to be discarded.
I learnt that Apache can use sockets to pass queries from the server to the application instance and pass the results back in turn. To explain how this feels unusual to the average webmaster you need to understand that for part of the configuration in Apache you are specifying fictional files and extensions in order to ensure the fast_cgi module works correctly but before we go there lets look at how the Catalyst application starts.
In the application folder there are a number of scripts which can run the application with its own test server or against a socket. Adding the startup script to /etc/rc.local ensures that the application is restarted and listening on the socket when the server is rebooted.
/home/useraccount/catapp/script/catapp_fastcgi.pl –listen /tmp/catapp.socket -n 6 -p /tmp/forumevents.pid -d
Here the catapp_fastcgi perl script configured the application to listen on the file /tmp/catapp.socket with a maximum of 6 new processes and to report its processid to /tmp/forumevents.pid and then to run in the background as a deamon.
That will get the Application started now you can configured Apache; you will need the fastcgi modules loaded and enabled in apache
../mods-enabled/fastcgi.load -> ../mods-available/fastcgi.load
../mods-enabled/fastcgi.conf -> ../mods-available/fastcgi.conf
The fastcgi.conf is configured as
AddHandler fastcgi-script .fcgi
FastCgiExternalServer /tmp/catapp.fcgi -socket /tmp/catapp.socket
Alias / /tmp/catapp.fcgi/
What caught me out when looking at the Documentation was the entry for FastCgiExternalServer there are a number of similar commands that look like FastCgiExternalServer and I was using them incorrectly. As you can see there is a mention to catapp.fcgi which is file that will not exist , its fictitous , so you need to get past it and accept that it is needed and you are expecting it to be there since it is used in the Alias command to point the server to the application.
That was it. A fastcgi implementation of Catalyst running under Apache and its very very FAST indeed. A Practical lesson learnt and a new technology under my belt. It fits neatly into the path for 12412.org I have set myself since this puts socket.io on my horizon and leads nicely back to my original plan for May; I learnt a little if indirectly a web technology and I gained some understanding of Catalyst on the road.