Latest Tweets:

run-it

I deployed a NodeJS Express app behind an nginx reverse proxy and wanted to have the node process supervised so it would automatically be restarted after crashes. I learned about a nifty service supervision suite called runit (inspired by D.J. Bernstein’s daemontools) from working at Cloudkick that would be perfect for the job.

runit has a prgram called runsvdir that monitors a particular directory for subdirectories that represent services. It launches a runsv process for every subdirectory and runsv executes a run script that you create to execute your service. In the Debian runit package, runsvdir watches /etc/service though you should create your service directory under /etc/sv and symlink it into /etc/service so you can test your run scripts.

The catch was, I wanted to run node with an unprivileged user and have the service directory in my home directory so I didn’t have to bother with sudoing. This is possible by having another runsvdir process monitor /home/mark/service. Here’s how I set it up:

/etc/sv/
|-- runsvdir-mark/
      |-- log/
      |    |-- main/
      |    `-- run*
      `-- run*  

/etc/service/
`-- runsvdir-mark@ -> /etc/sv/runsvdir-mark/

/etc/sv/runsvdir-mark/run:  
#!/bin/sh
exec 2>&1
exec chpst -u mark runsvdir /home/mark/service/

/etc/sv/runsvdir-mark/log/run:
#!/bin/sh
exec chpst svlogd -tt ./main/

.

With that, there’s now a runsvdir process monitoring /home/mark/service. I then created:

/home/mark/service
|-- aubergine-0/
      |-- log/
      |    |-- main/
      |    `-- run*
      `-- run*  

/home/mark/service/aubergine-0/run:
#!/bin/sh
exec 2>&1
exec chpst -e /home/mark/service/aubergine-0/env \
node /home/mark/code/aubergine/aubergine.js

/home/mark/service/aubergine-0/log/run:
#!/bin/sh
exec chpst svlogd -tt ./main/

Slow sudoing

I’ve been noticing that using sudo was taking an unusually long time to execute on my prgmr server—commands like sudo vim /tmp/foo would hang for 3-5 seconds before finally opening vim for editing. I assumed it was due to poor I/O in a shared environment, but it persisted for a while so I finally decided to investigate.

It turns out every time you use sudo, PAM tries to resolve your IP. There’s more detail in Redhat’s Bugzilla, bug #479464.

The solution is to add your hostname to /etc/hosts:

127.0.0.1 <HOSTNAME>.<DOMAIN> <ALIAS>

"To make it hard to quit they got a dog together. It’s supposed to be the company’s dog, not either of theirs individually. The idea being that now the company can’t go away or there’s no one to take care of the dog. Increased the burn rate a little but turned out to be a net win."

pg on the founders of WePay.

Floyd&#8217;s &#8220;tortoise and the hare&#8221; cycle-finding algorithm

I&#8217;d like to see Conrad Barski illustrate an algorithms book.

Floyd’s “tortoise and the hare” cycle-finding algorithm

I’d like to see Conrad Barski illustrate an algorithms book.

*1

Hung Up on SSH?

”~.” to disconnect.

Guilty Pleasures

I sometimes edit my .emacs file in vim.

Oy! Traffic Cops

I just discovered a show called Traffic Cops that airs on BBC One/UKTV People. It’s essentially the British version of “Cops” with less trash.

The British police look pretty spiffy in their uniforms and Volvos.

Slim-Vim

Larry Clapp announced that he is abandoning development on Slim-Vim.

:(

Spork Ion3

Tuomo Valkonen on Ion3: “I’m not going to make it easy for all the forkers…”

What a prick. I’m going to give xmonad a shot.

HTTP Referer

I was writing a WordPress plugin earlier today and noticed an inconsistency in spelling while referencing other plugins..

Wikipedia on Referrer: “Referer is a common misspelling of the word referrer. It is so common, in fact, that it made it into the official specification of HTTP – the communication protocol of the World Wide Web – and has therefore become the standard industry spelling when discussing HTTP referers.”

Use a spell checker next time, asshole.

Ellipses

Ellipses are too long. I prefer to use “..” as a fair middleground between a period and full-blown ellipsis.