I think I love supervisor

Supervisor is simple. It’s easy to use. It lets me start, stop, and monitor all my little processes:

$ supervisorctl status
celeryd                          STOPPED    Apr 15 03:17 PM
dropboxd                         RUNNING    pid 8442, uptime 1 day, 1:04:48
rabbitmq                         STOPPED    Apr 15 03:17 PM
redis                            STOPPED    Apr 15 04:08 PM

PyObjC and how to parse Preview.app bookmarks with Python

I wrote a Python program that parses Preview.app‘s bookmarks. The program itself is probably of dubious use, but it illustrates some interesting techniques like using class-dump to figure out how programs written in Objective-C work and how to use PyObjC to write Cocoa-style code with Python.

https://github.com/msabramo/print_os_x_preview_app_bookmarks

PyObjC allows you to write Python code that access the Cocoa libraries in a fairly intuitive way. The trickiest part of writing the program was figuring out how the data archived in the plist file was archived, so that I could write code to unarchive it. How did I figure out what the data looks like?

1. Install class-dump.

$ brew install class-dump

2. Run it (The awk is just to filter the output to show just the PVBookmark class).

$ class-dump /Applications/Preview.app | awk '/@interface PVBookmark/, /@end/ { print; }'
@interface PVBookmark : NSObject
{
    NSString *_UUID;
    NSString *_parentUUID;
    PVFileReference *_file;
    NSDate *_fileModDate;
    NSString *_label;
    int _pageIndex;
}

- (id)initWithFilePath:(id)arg1 label:(id)arg2 pageIndex:(unsigned long long)arg3;
- (void)dealloc;
- (id)initWithCoder:(id)arg1;
- (void)encodeWithCoder:(id)arg1;
- (id)description;
- (id)UUID;
- (id)filePath;
- (id)fileModificationDate;
- (id)label;
- (void)setLabel:(id)arg1;
- (unsigned long long)pageIndex;
- (id)targetExists;
- (BOOL)targetIsOnNetworkVolume;
- (id)displayPath;
- (unsigned long long)pageNumber;

@end

Manage rabbitmq-server with supervisor

First I installed rabbitmq:

$ brew install rabbitmq
...
==> make install
/usr/local/Cellar/rabbitmq/2.4.1: 114 files, 1.6M, built in 41 seconds

Running rabbitmq-server will start a server in the foreground, which is kind of inconvenient.

So I installed Supervisor:

$ pip install supervisor
Downloading/unpacking supervisor
  Downloading supervisor-3.0a10.tar.gz (438Kb): 438Kb downloaded
...
    Installing echo_supervisord_conf script to /Library/Frameworks/Python.framework/Versions/2.7/bin
    Installing pidproxy script to /Library/Frameworks/Python.framework/Versions/2.7/bin
    Installing supervisorctl script to /Library/Frameworks/Python.framework/Versions/2.7/bin
    Installing supervisord script to /Library/Frameworks/Python.framework/Versions/2.7/bin
Successfully installed meld3 supervisor
Cleaning up...

Then to set up Supervisor to manage rabbitmq:

$ echo_supervisord_conf > supervisord.conf
$ sudo mv supervisord.conf /etc
$ sudo vim /etc/supervisord.conf
...
$ grep rabbitmq /etc/supervisord.conf 
[program:rabbitmq]
command=/usr/local/sbin/rabbitmq-server

and then to start up rabbitmq and test that it’s working:

$ supervisord
$ supervisorctl status
rabbitmq                         RUNNING    pid 60340, uptime 0:00:04
$ rabbitmqctl status
Status of node 'rabbit@ladyproud-lm' ...
[{pid,60340},
 {running_applications,[{rabbit,"RabbitMQ","2.4.1"},
                        {os_mon,"CPO  CXC 138 46","2.2.5"},
                        {sasl,"SASL  CXC 138 11","2.1.9.3"},
                        {mnesia,"MNESIA  CXC 138 12","4.4.17"},
                        {stdlib,"ERTS  CXC 138 10","1.17.3"},
                        {kernel,"ERTS  CXC 138 10","2.14.3"}]},
 {nodes,[{disc,['rabbit@ladyproud-lm']}]},
 {running_nodes,['rabbit@ladyproud-lm']}]
...done.
$ rabbitmqctl list_exchanges
Listing exchanges ...
amq.direct      direct
amq.topic       topic
amq.rabbitmq.log        topic
amq.fanout      fanout
amq.headers     headers
        direct
amq.match       headers
...done.

Another OS X 10.6.7 kernel panic that seems to indicate Canon printer/scanner driver problems

OS X 10.6.7 kernel panic mentioning "Canon IJ Network"

This is at least the fourth or fifth time that I’ve had a OS X 10.6.7 kernel panic that said “BSD process name corresponding to current thread: Canon IJ Network” (what I just saw a few minutes ago on my work MBP) or “BSD process name corresponding to current thread: CIJScannerRegist” (seen in the past).

I am very suspicious of the quality of Canon’s printer/scanner drivers for Snow Leopard (also see this earlier post of mine and this one too).

Site back

Some of you noticed that my site was down (500 internal server error) Friday and some of Saturday. I’m not exactly clear on how it happened, but PHP became broken on my VPS. I think the culprit was that the file /usr/lib/libcurl.so.3, which PHP was dynamically linking to, somehow seemed to disappear. It’s not clear to me whether I somehow did this accidentally (though I have not done much lately on the server) or if it happened through other means. Anyway, once DreamHost and I determined what was actually going on, DreamHost support reset the VPS and things came back to life.

Somehow this seemed to do something to another domain I have that uses Phusion Passenger for Python WSGI for Django — basically the Passenger stuff seemed to break and it was not launching Phusion Passenger WSGI’s request_handler.py. I had a few exchanges with DreamHost on this and then this morning suddenly it was working again. Not sure if DreamHost did something to fix it or if it was just the planets suddenly aligning.