Mac OSX: starting postgres on boot

July 3rd, 2008

Every bloody operating system has it's own unique way of starting things at boot time. Today I bothered to learn how OS X does it. Here's how I got PostgreSQL to start when my machine is turned on:

What gets started is handled by a program called SystemStarter. On boot it looks through /Library/StartupItems for folders. Inside those folders it looks for a script with the same name as the folder and a plist called StartupParameters.plist.

So as super user:

cd /Library/StartupItems/
mkdir PostgreSQL
touch PostgreSQL/PostgreSQL
touch PostgreSQL/StartupParameters.plist
 

Now we need to fill in the details. In PostgreSQL/PostgreSQL enter:

#!/bin/sh

sudo -u postgres /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/logfile start

This is a long line, but it's basically running postgres (via pg_ctl) as the user postgres. You'll need to change this to the whatever user you run postgres as and where ever your install of postgres is. I've used the standard names and directories so it's likely this will work for you too.

Now lets look at the plist. This file contains information for SystemStarter about when to start postgres, what postgres needs and provides and any messages to print to log files:

 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
        <key>Description</key>
        <string>PostgreSQL</string>
        <key>Messages</key>
        <dict>
                <key>start</key>
                <string>Starting PostgreSQL</string>
                <key>stop</key>
                <string>Stopping PostgreSQL</string>
        </dict>
        <key>OrderPreference</key>
        <string>None</string>
        <key>Provides</key>
        <array>
                <string>PostgreSQL</string>
        </array>
</dict>
</plist>
 

You can test your new settings by typing sudo SystemStarter -n -D, fix any error messages, reboot and you should have postgres all the time :)

I have a shameful secret: as an engineer…

June 24th, 2008

... I have no idea how to fix twitter. I know this sounds incredible but it is true, there I have said it, it's out in the open.

I use twitter every day to send out really quite boring messages. "I've had some chocolate" and "I like lossless encoding" are all stunning examples of how boring my twitters are. Sometimes they don't appear on twitter for hours... occasionally they don't appear at all.

As an engineer I think I have a fair idea of how twitter works BUT I have a code base full of my own problems. I tend to spend my time thinking about those rather then fixing twitters by proxy.

So I'm asking the internet, can you all just shut up about fixing twitter. I am sure they are aware of their deficiencies and how it would be better if they didn't do X or did do Y. Let's leave it to them to solve and if they don't I'm sure one of the genius twitter fixing bloggers can make his own distributed erlang über resilient systems that only blogger can create.

Here endeth the rant!

Password, it’s just not obvious to normal people

May 20th, 2008

As a programmer and all round geek I spend a lot of my time thinking about user interfaces for normal people. This is probably the hardest aspect to programming.

Putting yourself in the place of a normal user is, basically, impossible but every programmer/ui designer attempts to do this EVERY day.

Why am I talking about this? Well my dad's hotmail account was hacked over the weekend and of course I was called to look in to it. Of course my first thought was that he had a weak password. So I ask him "How good is your password, does it contain numbers and puntuation?". He paused and said "No, it's a word, they asked for a pass WORD".

Now it's easy to think that this is my dad's fault. But when you think about it, he did exactly what was asked of him. He entered a pass WORD a single word. A word from the dictionary, that's where words come from for normal people.

No one programmer or designer has failed him. An entire industry asks to world for passwords. To the industry, this is normal. It knows what it means by password but to normal people it means a word.

With this in mind I've raised a ticket for New Metal Army to change the word password to pass phrase (after asking my dad what he thought it meant of course).