August 2009 Archives

Perl at pair Networks

| | Comments (0)

pair Networks has been using Perl for its software infrastructure since it opened back in 1996, and has been supporting Perl-related events, including the Italian Perl Workshop, for many years. In the August 2009 pair Networks Insider Newsletter, developer Alan Ferrency explains some things about the Account Control Center, which is built in Perl.

This excerpt from the August 2009 newsletter (section 4, Developer's Corner: An Introduction ) is republished with permission from pair Networks, Inc.


Hello, and welcome to Developer's Corner. I'm Alan Ferrency, Lead Software Developer of the pair Networks Account Control Center (ACC) team, and I'll be your guide.

In Developer's Corner, I'll present articles on a variety of topics useful for technically oriented pair Networks Web hosting customers. Web site developers, webmasters, and anyone making technical decisions about Web sites will feel at home here.

I'd like to start by describing some of the software we use internally at pair Networks to give you an idea of some topics to expect in future articles.

As many of you know, pair Networks strongly supports the use and development of Open Source Software. Most of our internal systems depend heavily on Open Source Software, and the Account Control Center is no exception.

The ACC Web interface is written in Perl and runs in Apache using mod_perl. We use the Text::MicroMason templating engine and an internally developed application framework. The back end subsystems used by the ACC are also primarily written in Perl.

Unlike other configuration systems, the ACC runs on internal servers to avoid wasting system resources on your Web hosting server. Our developers work on private virtual development servers equivalent to a pair Networks VQS, and our production servers start life as standard QuickServe dedicated servers.

Our customer support systems are also built on Open Source. Our support request tracking system is written in Perl and integrated with the ACC and internal customer support tools. The phone system uses the Asterisk voice over IP (VoIP) telephony system as well as custom Perl and Ruby code.

pair Networks developers have contributed bug reports, patches, and features to a variety of Open Source projects we use here: FreeBSD, Perl, Dovecot, and tcsh to name a few. Some Perl modules developed for internal use are also publicly available and actively maintained on CPAN.

The combination of off-the-shelf Open Source systems and custom code allows us great flexibility in developing internal systems. As a pair Networks customer, you have access to the same hardware and tools we use to build our systems. In future months, I'll describe ways that you can take advantage of this to improve your Web sites and businesses.


By the way, pair Networks is also a great hosting solution for the deployment of Perl applications: I'm a long time customer, so I can tell. :-)

This was the year of the comeback to YAPC::EU for me, after the only one I attended to in 2000 (or, better, in 19100) in London. Since I'll be one of the organizers of next year conference in Pisa, I thought I should really go and take a look (joking, I was going to be there anyhow).

By the way, Pisa was chosen for the 2010 of the YAPC::EU, that is to say I and other (mostly Italian) Perl enthusiasts will organize it. It's a bit scary when I think about it, but it's also an exciting challenge and I'm confident we'll be able to work well. We'll have to make ourself ridiculous enough by performing a part of the Rocky Horror Picture Show just before the Pisa YAPC... this is really scary.

The conference

The YAPC was, put it simple, a great conference. Most of the talks were interesting and enjoyable, with so many important speakers: you can have a look at the conference web site to see who they were.

My favourite talks were the ones related to functional programming (if I only had the time to dig this a bit more...), Moose, Devel::Declare, perl 6 regular expressions, and some other topic I can't remeber right now. I was also quite interested in the Padre editor, even though I'm not using it (yet?): having a good software in this are written in Perl could help the language to be seen as a viable option for areas such as GUI programming - moreover, Padre works well.

As expected, it was very nice and interesting to talk with people around the conference, see "old friends" (including the Italian folks I don't meet that often, after all), meet new ones, speak with the conference sponsors. It was especially nice to meet Dirk from Vlaanderen.pm again (after the London Perl Workshop 2008) and to know about Belgian Perl Workshop 2010, an event I unfortunately missed in 2009.

Coffee breaks were great, with file local pastries to choose from; the only thing I can say about that is that the coffee wasn't spectacular(as the one we use to serve at Italian Perl Workshop ;-). Lunches were good as well, with pizza slices and sandwiches: for conferences, I like this "pick up something when you want and" style much better than something like "sit down at 12:30".

As usual I wasn't able to keep my wallet locked: I bought 5 books at O'Reilly table (including a Mercurial one I'll probably never user) and a Shadowcat YAPC-dedicated t-shirt at the auction: wicked design, by Mark Keating - great t-shirt!

Around the conference

Evenings are always an interesting part of these events, as they offer the ideal environment to speak about technical and not technical matters... and they give plenty of opportunities for food and drinks. :-)

First social evening was the pre-meeting. There was supposed to be some early registration process, but there wasn't (or we weren't able to find where it was being done ;-)). The place was a big Irish pub in the Oriente district, a nice and modern part of the town, albeit a bit windy. It was good to be in a place where to drink beers which were more interesting than the local lagers. Too bad a conference attendee sitting next to me (I can't remember his name now) commented against my Talisker t-shirt: he liked Lagavulin better. :-)

The attendees dinner was in downtown Lisbon, in a waterfront restaurant, and it all revolved around very good meat... and also around caiprinhas, which were barely drinkable to say it all. I really have to mention the British-Italian quiz show team (osfameron and polettix), which achieved an honourable second place at the quiz show (hosted by Damian Conway).

I was also invited, as an organizer of next year's YAPC, at the speakers dinner, which was just nearby the Irish pub of the pre-meeting. Good meat to eat there as well. At the end of all of this, I have to say that Portuguese food is quite heavy as far as calories are concerned, but very tasty.

Lisbon

The city was a pleasant surprise for me. I decided not to sleep at the hotel suggested by the conference organizers, which was near the conference but a bit far from the downtown, and chose an hostel (Lisbon Poets Hostel) in Chiado. It proved to be a nice choice, as it allowed me to take a look at the city centre when going to and coming back from the conference or evening meetings.

The hostel had free Wifi, so I could keep in touch and even work a bit. As usual I chose to sleep in a dormitory (4 beds), which is a good way to save some money and to meet people. This time, however, I shared the room with 3 French girls and we didn't catch that much; oh well, no problem.

I had the chance to wander around the city centre and found it to be enjoyable: trams, small alleys, and fine buildings make it a very enjoyable place - and there are really a lot of people around. I also took a night bar crawl in the Bairro Alto with some people at the hostel: it lasted until 5AM and we drank way too many beers. The Bairro is a nice place however: everybody's friend of everybody and it's very easy to meet new people.

xfce4 is a lightweight (compared to Gnome and KDE) which I happen to love, as it still provides nice theming, a well-done panel system and some interesting goodies. The window manager (xfwm4) is not handy as others. xmonad is, however, a great one, in particular: tiling, highly customizable and... written and extendable in Haskell!!! So, it makes up for a good replacement.

I decided to change xfce's window manager and use xmonad. The thing required a few steps in order to begin working properly. Here's a tutorial which presumes you use the following software versions:

xfce 4.6.1
xmonad 0.8.1
gmrun 0.9.2
dmenu 4.0

This is a screenshot of how it's going to look like.

I also assume you have a working xfce4 installation and you're able to login to the xfce desktop with an account (by the way, I suggest slim as login manager).

First of all, you need to emerge xmonad (after unmasking it in /etc/package.keywords):

emerge -av xmonad xmonad-contrib

xfce configuration

The first thing is to properly configure xfce. My suggestion is to open the Desktop settings dialog box and, in the Icons tab, uncheck all default icons: it's a tiling window manager, and having icons around will only leave a box containing them which is going to look weird. You're not migrating to a tiling window manager to use desktop icons, aren't you? ;-)

Switching from xfwm4 to xmonad is a bit tricky, as xfce4 doesn't support (like Gnome and KDE do) configuring the window manager at all, and xmonad doesn't support the session protocol (so we must ensure that xmonad is started every time we log in). So, just login with your account, open a terminal and then terminate xfvwm4 while launching xmonad:

kill `pidof xfvm4` && xmonad &

The window manage should be replacing (you'll notice your windows tiling). At this point exit xfce4 saving the session: this will ensure xmonad is started again when you log back in. Problem is xfce will also try to start xfvwm4: to avoid this you have to locate you session file in ~/.cache/sessions and remove the entry for xfvwm4.

At this point you should be able to login again and xmonad will be your new default window manager.

xmonad configuration

xmonad needs a some tweaking to play well with xfce, and also to be more usable on its own.

Looking into you ~/.xmonad directory you'll find a xmonad.hs file which is used to compile xmonad (the xmonad-x86_64-linux binary in the same directory, with the name changing depending on your arch) when starting it for the first time. The configuration file is in Haskell, so it might look a bit weird if you haven't seen the language before. The instruction given below might vary if you xmonad.hs is a bit different, or if you already customized it somehow.

First of all, we need to ensure xmonad properly manages the xfce4 panels (I have one, at the bottom), by placing them where you expect them to be, by making them visible in all workspaces and by avoid application windows to overlap them. Add this line after the other import ones:

import XMonad.Hooks.ManageDocks

Locate the:

myLayout = tiled ||| Mirror tiled ||| Full

and change it to:

myLayout = avoidStruts(tiled ||| Mirror tiled ||| Full) 

Then locate:

myManageHook =  composeAll
    [ className =? "MPlayer"        --> doFloat
    , className =? "Gimp"           --> doFloat
    , resource  =? "desktop_window" --> doIgnore
    , resource  =? "kdesktop"       --> doIgnore ]

and replace it with the following code. It's actually a small change but I chose to create an extra variable for the sake of clarity.

stockManageHook =  composeAll
    [ className =? "MPlayer"        --> doFloat
    , className =? "Gimp"           --> doFloat
    , resource  =? "desktop_window" --> doIgnore
    , resource  =? "kdesktop"       --> doIgnore ]
myManageHook =  manageDocks <+> stockManageHook 

Now that we ensured the panels get a proper placement, we'd better change the default xmonad mod key: the default left Alt conflicts with the shortcuts of many applications, including xfce terminal, firefox, and others. Luckily, we have an otherwise almost useless "Windows start" key on the left of the keyboard; to use that as mod key find this line:

myModMask       = mod1Mask 

and change it to:

myModMask       = mod4Mask 

I suggest you delete the binary inside the .xmonad directory before logging back in, in order to ensure it's compiled again.

additional software

In its default configuration, xmonad provides key binding for a couple of useful softwares.

gmrun (mod+shift+p) opens a small text box where you can enter the name of a command to launch. You can also use xfce's own "Run program..." feature of course.

dmenu(mod+p) opens a nice menu bar (at the top by default) which lists what you have in /usr/bin (by default) and can be used to launch programs by just typing a few letters and navigating the list. Very handy.

Well, that's it: you should have everything working now. Exercise your hands and fingers for xmonad. ;-)