St Albans Carol Services

December 18th, 2011

We've got the best Carol Services in all of St Albans!

Both are on 18th December (today!)

10:30am Family Carol Service - a fun service for all ages, with the Kids' Nativity (lasts about an hour)

4:00pm Carols by Candlelight - a more traditional service of carols and Bible readings (lasts about 75 minutes)

Both have delicious refreshments afterwards.

Come along and get into that Christmas spirit!!!

Click here for more info on: the best Carol Services in St Albans

mod_fcgid, timeouts, and downloads

November 3rd, 2011

Or,

(104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
(104)Connection reset by peer: mod_fcgid: ap_pass_brigade failed in handle_request_ipc function

And

mod_fcgid: read data timeout in 40 seconds

There's not a lot around that is helpful about these errors, so after having to try to sort them out myself, here's a report on what I've found. It's got to be worth telling you, I was up til 1am.

Summary

FcgidBusyTimeout (old name BusyTimeout) is the setting that governs the first error. Set to default and a download initiated by php will timeout after about 450 seconds, giving:

(104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
(104)Connection reset by peer: mod_fcgid: ap_pass_brigade failed in handle_request_ipc function

I think that "about 450 seconds" is a combination of 300 seconds for the FcgidBusyTimeout setting, and 120 seconds for the FcgidBusyScanInterval, and some fudge time :)

Only people with slow download speeds / downloading large files will force this error.

FcgidIOTimeout (old name IPCCommTimeout) governs the read data timeout error. A php script that waits for something to happen (like a download to finish) will timeout after 40 seconds when this is at its default setting, giving:

mod_fcgid: read data timeout in 40 seconds
Premature end of script headers: scriptname.php

Solution

FcgidBusyTimeout 3600
# or whatever big number you want
# 3600 (seconds) allows an hour for a download
#
FcgidIOTimeout 600
# or whatever
# 600 seconds allows 10 minutes for a script to wait
# you just need to adjust it to suit the scripts you run

Where?

In this section, in httpd.conf, before the virtual hosts:

<IfModule mod_fcgid.c>
FcgidBusyTimeout 3600
FcgidIOTimeout    600
# other Fcgid directives...
</IfModule>

Alternatively, if you're running CPanel+WHM, use the include editor: Service Config > Apache Config > Include Editor > Pre Virtual Host Include

More Detail

Here's an annotated selection of mod_fcgid settings for httpd.conf:

<IfModule mod_fcgid.c>
# Set a maximum number of requests a process will handle,
# then it'll die # this is just to keep memory cleaned up # somewhere I've read that a php process will die after 500,
# whatever you set here # but you need to set 500 here as well! FcgidMaxRequestsPerProcess 500 # # These two govern how many processes are created, # but I'm using defaults so I've commented them out # FcgidMaxProcesses 6 # FcgidMaxProcessesPerClass 6 # # What's the least number of processes for a class? # not sure what a 'class' is, but set this zero # to enable processes to be killed off FcgidMinProcessesPerClass 0 # # Now some idle settings # # Scan interval, fairly straight forward – how often it checks FcgidIdleScanInterval 30 # # How long should a process be idle for before we kill it? FcgidIdleTimeout 300 # # How old do you want processes to get? # Once they get to this number, they'll be killed once they're # idle, regardless of FcgidIdleTimeout # its another way of doing what FcgidMaxRequestsPerProcess does, # but with time instead of requests FcgidProcessLifeTime 3600 # # What about a process waiting for a connection to be made? FcgidConnectTimeout 100 # # And this is a timer for a script that has connected, # but is waiting for input/output to happen, # like a script waiting for an upload FcgidIOTimeout 600 # # a FastCGI application will be killed after handling
# a request for FcgidBusyTimeout # This is the one that kills long downloads # - the download is busy, but waiting, so it times-out FcgidBusyTimeout 3600 # # This is self-explanatory, the interval that 'busy' is checked FcgidBusyScanInterval 120 # # And last, but not least, the size of requests that can be made # needs to be bigger than any upload you want to do FcgidMaxRequestLen 100000000 </IfModule>

Integrating PHPLIST into Magento

July 19th, 2011

Looking to integrate a Magento Store with a PHPLIST email database? Here are some files to help you.

Background

I'm working on moving the Maynard's Groovy Bible Tunes Store onto Magento, and one of the important things for me is to be able to continue to use PHPLIST for my email newsletters.

Unfortunately there doesn't seem to be a PHPLIST module for Magento. However there is one for OsCommerce which I've been using, and so I set about using / modifying it to get it to work with Magento.

It turned out to be easier than I expected. Having said that, I haven't made a proper module - if you want to install this, it's a DIY job. Tools you will need are: an FTP client, a text-file editor.

What it does

A user subscribes to the newsletter via their Magento page, and that gets copied over automatically to your PHPLIST setup. When you next send a PHPLIST newsletter, all your Magento store newsletter subscriptions are included.

When users (or admin) modify subscriptions via Magento or PHPLIST, the other database is updated.

NB: The Magento database is only updated when the user / admin next views newsletter subscription info via Magento.

More techically: the modifications intercept any changes made to a user's subscription to the Magento newsletter, and updates the PHPLIST database accordingly. Furthermore, when a user (or the admin) checks his Magento Newsletter subscription, the PHPLIST database is checked in case the user has changed his subscription via the PHPLIST interface, and the Magento database is updated accordingly.

The files are installed in a folder that overrides core Magento files without corrupting them. This way your underlying installation is kept safe, and completely upgradeable.

It's tested and working on Magento 1.5

Installation

Here's what you need to do:

1. Don't try this on a working store.

Experiment on your private server, and make sure it works with your setup before going live.

If you break your PHPLIST or Magento setups with this, it's not my fault.

2. Backup everything

Databases, files, anything you can think of. From now on if anything goes wrong it really is not my fault.

3. Create some folders

You need to create this folder structure in your store's root directory: app/code/local/Mage/Newsletter/Model/

Some of it will be there already, just create the extra folders.

By creating this structure, the new files you use simply override the Magento core files, without corrupting them at all. You can upgrade Magento, and the core files get changed properly, as well as the modification remaining in place.

You can remove the mod at any time just by deleting its files.

4. Copy the new files into place

Put these four files into app/code/local/Mage/Newsletter/Model/

  • Subscriber.php
  • MGBT_phplist_define.php
  • MGBT_phplist.php
  • MGBT_database.php

Download them from here: PHPLIST_Magento.zip

5. Edit MGBT_phplist_define.php

You need to provide configuration details that match your PHPLIST setup. Information is in the file.

6. Try it out.

Try subscribing / unsubscribing to the newsletter in Magento, and watch how PHPLIST gets the info.

Try changing a subscription in PHPLIST, and watch how Magento picks up the info!

If it doesn't work - sorry, you can either try contacting me to see if I can help, or just delete the files you copied in, and nothing will be broken. Unless you've made a mistake following my instructions, in which case you made backups at step 2, so use them.

7. TODO

I haven't written a script to synchronise two existing databases. Sorry.

AV - Simulated Election results for Single Transferrable Vote

April 27th, 2011

With the Referendum for AV coming up on May 5th, I wondered what effect the "Single Transferrable Vote" would have had on the 2010 election. So I got the election data from the Electoral Commission (http://www.electoralcommission.org.uk/elections/results/general_elections), and simulated an AV election...

You can draw your own conclusions from the results...

Assumptions

Obviously I had to make some assumptions, so I ran the simulation three times, with different assumptions.

I rated the political parties Left/Right wing on a scale of 1 (very Left Wing) to 5 (very Right Wing), so that (and you can argue with this...) Labour = 2, Lib Dems = 3, Conservative = 4. I made educated guesses for all the other parties, and may have got this wrong for some. I gave Independents a "flat" rating - which made them equally loved (or hated) by every persuasion.

Election 1 - Similar politics, votes transferred by proportion of vote

In other words, I tried to share the loser's votes with parties of similar politics. If there was more than one such party, they got the loser's votes by the proportion of their existing total vote. If there weren't any parties with similar politics, I went wider. This meant that when Lib Dems votes were transferred, most of the time they went by proportion to both Con and Lab. That probably won't happen for real.

Here's the result:

Party Seats +/- seats from 2010
Conservative Party 318 +32 -20
Labour Party 200 +4 -62
Liberal Democrat 101 +44 -0
Sinn Fein 8 +4 -1
Scottish National Party 6 +0 -0
UCUNF UUP and CON joint party 5 +5 -0
Plaid Cymru 3 +0 -0
Independent 3 +2 -0
Social Democratic & Labour Party 1 +0 -2
Independent Save Our Green Belt 1 +1 -0
Alliance Party 1 +0 -0
Traditional Unionist Voice 1 +1 -0
Respect Party 1 +1 -0
Speaker 1 +0 -0

Election 2 - Similar politics, by proportion, except Lib Dems vote against lead party in each seat

So if Con are 1st, Lab 2nd, LD 3rd, with no clear majority, the LD votes will all go to Lab.

Party Seats +/- from 2010
Conservative Party 299 +87 -94
Labour Party 219 +77 -116
Liberal Democrat 101 +44 -0
Sinn Fein 8 +4 -1
Scottish National Party 6 +0 -0
UCUNF UUP and CON joint party 5 +5 -0
Plaid Cymru 3 +0 -0
Independent 2 +1 -0
Social Democratic & Labour Party 1 +0 -2
Independent Community and Health Concern 1 +1 -0
Alliance Party 1 +0 -0
Traditional Unionist Voice 1 +1 -0
Respect Party 1 +1 -0
Speaker 1 +0 -0
Independent Save Our Green Belt 1 +1 -0

Election 3 - As above, but Lib Dems now only transfer to Labour

Who knows, it could happen?

Party Seats +/- from 2010
Labour Party 309 +80 -29
Conservative Party 210 +1 -97
Liberal Democrat 101 +44 -0
Sinn Fein 8 +4 -1
Scottish National Party 6 +0 -0
UCUNF UUP and CON joint party 5 +5 -0
Plaid Cymru 3 +0 -0
Independent 2 +1 -0
Social Democratic & Labour Party 1 +0 -2
Independent Community and Health Concern 1 +1 -0
Alliance Party 1 +0 -0
Traditional Unionist Voice 1 +1 -0
Speaker 1 +0 -0
Independent Save Our Green Belt 1 +1 -0

Complete Results

Here's a PDF of my complete results - including how all the votes got transferred: AV Simulated Elections.pdf

Windows Update - "Checking for updates" goes on and on... Fixed!

March 7th, 2011

All of a sudden I realised that I hadn't had any Windows 7 updates in a while - so I decided to check "Windows Update" (from the Start Menu - just type 'update' in the search box) - and discovered that there was a problem.

I clicked "Check for Updates", and the page changed to the "Checking for Updates" page, with the moving progress bar. And there it stayed, for hours, doing nothing. No error, no timeout, no nothing.

So I dug a little deeper - the System Tools Event Viewer showed a System Event error:

"The Windows Modules Installer service terminated with the following error: The specified module could not be found." - Event ID 7023

What's more, if I tried to start the "Windows Modules Installer" service from services.msc, I got a similar error.

Hmm - something was wrong with "Windows Modules Installer" - whatever that was. Anyway - the long & short of it is, I eventually found a page with the solution. It's here: http://www.vistax64.com/tutorials/282940-windows-modules-installer-error-126-fix.html

Yes, it's a Vista page, but the "Fixing Key" part was what sorted it for me.

The error I had was that the version number in C:\Windows\Servicing\Version was different to that in the Registry key in
HKLM\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\Version

The web-page I've linked to shows you how to change the registry to have the right version number. Once I'd done that, BANG! Windows Update swung into action without me having to anything else.

Phew. I was just about to line up a complete re-install of windows...