Dead Ink Vinyl

Musings of David L Kinney

Posts Tagged ‘apple

CouchDB on MacOSX Leopard

I got CouchDB up and running as a service on my MBP OSX Leopard this past Monday. It wasn’t as straight-forward as I’d hoped, so I thought I’d share my process for the benefit of others.

Installing CouchDB

I installed CouchDB from source. This requires the Leopard development tools (Xcode) and MacPorts. I expect all developers to have Xcode installed and most developers to have MacPorts installed, so I won’t detail those steps here.

First, install CouchDB’s dependencies using MacPorts:

sudo port install icu erlang spidermonkey

Download CouchDB and extract it. This is standard configure, make, make install territory here:

./configure
make && sudo make install

Wasn’t that easy?

Creating a couchdb System Account

Find a user number that is available. To see a list of what numbers are already in use, run:

dscl . -list /Users UniqueID | awk '{print $2}' | sort -n

Now find a group number that is available. To see a list of what numbers are already in use, run:

dscl . -list /Groups PrimaryGroupID | awk '{print $2}' | sort -n

On my system, number 103 was available for both a user number and a group number. The rest of this article assumes you are using 103 as well.

The following commands create the group and the user and set the user’s home directory to the CouchDB lib folder.

sudo dseditgroup -o create -i 103 -r "CouchDB Users" couchdb
sudu dscl . -create /Users/couchdb
sudu dscl . -create /Users/couchdb UniqueID 103
sudu dscl . -create /Users/couchdb UserShell /bin/bash
sudu dscl . -create /Users/couchdb RealName "CouchDB Administrator"
sudu dscl . -create /Users/couchdb NFSHomeDirectory \
        /usr/local/var/lib/couchdb
sudu dscl . -create /Users/couchdb PrimaryGroupID 103
sudu dscl . -create /Users/couchdb Password *

Finally, we give the couchdb user ownership of the CouchDB lib and log directories:

sudo chown -R couchdb:couchdb /usr/local/var/<strong>lib</strong>/couchdb
sudo chown -R couchdb:couchdb /usr/local/var/<strong>log</strong>/couchdb

DONE! Now you can launch CouchDB as the couchdb user instead of root.

sudo -u couchdb couchdb

Running as a Service

To control CouchDB using launchctl, I needed to add the appropriate PATH information to CouchDB’s Launch Daemon plist so that gawk is found. Unfortunately, I couldn’t find a solution to edit the plist in-place as a privileged user, so I copied the file to the /var/tmp directory without root privileges so that I could update the copy.

Creating a copy of the plist and opening it for editing is done by:

cp /usr/local/Library/LaunchDaemons/org.apache.couchdb.plist \
        /var/tmp/org.apache.couchdb.plist
open /var/tmp/org.apache.couchdb.plist

In the Property List Editor that opens, follow this steps:

  1. Open Root → EnvironmentVariables
  2. Click on Add Child
  3. Name: PATH
  4. Value: /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin
  5. File → Save
  6. Quit Property List Editor

Then copy the updated plist over the original plist:

sudo cp /var/tmp/org.apache.couchdb.plist \
        /usr/local/Library/LaunchDaemons/org.apache.couchdb.plist 

Now CouchDB can be controlled and monitored by the standard Leopard daemon manager:

sudo launchctl load \
        /usr/local/Library/LaunchDaemons/org.apache.couchdb.plist 

Launch CouchDB on Startup

To automatically launch on start up, run

sudo ln -s /usr/local/Library/LaunchDaemons/org.apache.couchdb.plist \
        /Library/LaunchDaemons/org.apache.couchdb.plist

Congratulations! You have CouchDB running as a system service that will start when you boot your Mac. Let the fun commence.

I’d Like to Thank the Academy…

I’d like to thank the following sites and resources for providing me enough information to piece together the process:

I particularly recommend the evang.eli.st article, as it explains the dscl command, which may be an unfamiliar account management tool.

I should point out that evang.eli.st also has a complete write-up on how to install CouchDB on OSX. That walk-through is almost a year old, though, and entails editing the Makefile—which doesn’t sit well with me. However, where Leopard departs from standard UNIX behavior, I cease being an aficionado, so his tweaks may be important in ways I haven’t yet discovered.

Written by dlkinney

July 12, 2008 at 9:39 pm

Understanding Apple’s Revenue Streams

The excellent blog Going Private discusses Apple’s new iPhone revenue model, whereby Apple allowed AT&T to subsidize the price of the iPhone (leading to more iPhones being sold) but gave up the profit-sharing on new iPhone service contracts. The deal is analyzed entirely from the perspective of whether the increased sales volume offsets the lost service contract revenue:

I suspect the figures are pretty offsetting, leaving any future gain in iPhone revenue as a percentage of total revenue really subject to iPhone sales growth v. other sales growth at Apple… and not the new revenue model which is probably pretty neutral.

I didn’t see a way to leave a comment, so I’ll post my comment here. If the only components to this deal were subsidies and contract revenue, then it would be a nearly complete win for AT&T. But this analysis fails to account for the additional revenue that Apple will gain through the App Store selling applications to iPhone (and iPod Touch) owners.

The service contract revenue lost by the new deal is not offset against increased hardware sales—it is offset against App Store revenues. The more people who own iPhones, the more revenue the App Store can be expected to generate. Apple gave up contract revenue primarily in exchange for permission to run its own store selling software over-the-air directly to the iPhone device. In the traditional mobile marketplace, it is the carrier who sells applications and keeps a generous percentage of the application price. Apple negotiated with AT&T (and, apparently, dozens of other carriers internationally) to allow iPhones to purchase and download applications from Apple’s App Store. To secure this, Apple agreed to no longer take a cut of the iPhone service contracts. Additionally, Apple will allow AT&T to subsidize the iPhone, which is now good for both parties. (This new arrangement is apparently much more pleasing to carriers internationally as well, giving Apple more markets in which to sell its product.)

It’s a win for AT&T because they can attract (or retain) many more customers and they no longer split those contract revenues with Apple. Additionally, I suspect that AT&T even gets a small cut of the 30% Apple keeps for applications sold over-the-air through the App Store to AT&T customers.

Apple wins by dramatically increased hardware sales and the right to sell apps over-the-air to iPhones. And the App Store benefits from networking effects. The more people who own iPhones, the more developers will be attracted to build and sell applications in that marketplace. The more applications there are in that marketplace, the more people will want iPhones. The iPhone’s killer app will no longer be it’s revolutionary interface and ease of use, but rather be the applications that run on it. Finally, Apple wins by attracting huge numbers of new developers to its operating system, libraries, and development tools. John Gruber reports that “two engineers from Apple told me that [interest] wasn’t just for the iPhone — that they were seeing plenty of new-to-Cocoa developers in the Mac-specific sessions and labs, too”.

Everyone benefits.

Written by dlkinney

June 22, 2008 at 11:01 am

WWDC Prediction Outcomes

WWDC isn’t over yet, but we learned a lot today. Let’s see how I did with my predictions.

Category My Prediction Correct?
iPhone
3G Yes Correct
GPS Yes Correct
Faster Processor No Correct
Video Conferencing No Correct
Thicker (face-to-back) Yes Correct1
iPhone mini Yes Incorrect
Higher Pricing Yes Incorrect
SquirrelFish Yes ?
iPhone widgets No Correct2
Apple Software
OSX 10.6 Will Be Announced Yes Correct
OSX 10.6 Named Snow Leopard Yes Correct
OSX 10.6 Specifically be for Atom Devices No Correct
OSX 10.6 OSX 10.6 Will Drop PPC Support Yes ?
OSX 10.6 Will Drop Carbon Support Yes ?
New / Improved / Revamped .Mac Services Yes Correct
.Mac Rebranding Yes Correct
Apple Hardware
New Apple Device No Correct
New MBP Designs Yes Incorrect
New Displays No Correct
Pie In the Sky Prediction
OSX 10.6 Adds Resolution Independence Yes ?

Outcome: 13 correct, 3 incorrect, and 4 unknowns. So my prediction accuracy is 65%-85%, depending on how the unknowns turn out. Not bad, given that 10% of my predictions were complete guesses.

1 The original iPhone was 11.6mm thick, according to Apple’s support site and the new iPhone is 12.3mm according to the new iPhone site.

2 No discussion of a DashCode for iPhone or HTML+JavaScript+CSS application development solution was stated during the keynote. If it comes to my attention that widget iPhone development is possible, I will toggle my answer’s correctness.

Written by dlkinney

June 9, 2008 at 7:33 pm

Follow

Get every new post delivered to your Inbox.