<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>necessary and sufficient</title>
	<atom:link href="http://shortbus.org/bloggin/feed/" rel="self" type="application/rss+xml" />
	<link>http://shortbus.org/bloggin</link>
	<description>blog is so computer</description>
	<pubDate>Thu, 23 Oct 2008 07:33:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>making a manifest for SMF</title>
		<link>http://shortbus.org/bloggin/2008/10/22/making-a-manifest-for-smf/</link>
		<comments>http://shortbus.org/bloggin/2008/10/22/making-a-manifest-for-smf/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 07:33:38 +0000</pubDate>
		<dc:creator>peter</dc:creator>
		
		<category><![CDATA[shortbus]]></category>

		<category><![CDATA[example]]></category>

		<category><![CDATA[instances]]></category>

		<category><![CDATA[mt-daapd]]></category>

		<category><![CDATA[smf]]></category>

		<category><![CDATA[solaris]]></category>

		<guid isPermaLink="false">http://shortbus.org/bloggin/?p=24</guid>
		<description><![CDATA[Sun is an incredibly frustrating company. A number of the new features introduced in Solaris 10 are very excellent, but I find all the Solaris userland a huge shitpile compared to my familiar GNU tools. Furthermore, the documentation for the aforementioned excellent features is pretty lacking at times, meaning a lazy dude like me gets [...]]]></description>
			<content:encoded><![CDATA[<p>Sun is an incredibly frustrating company. A number of the new features introduced in Solaris 10 are very excellent, but I find all the Solaris userland a huge shitpile compared to my familiar GNU tools. Furthermore, the documentation for the aforementioned excellent features is pretty lacking at times, meaning a lazy dude like me gets little use out of them. However, I just finally stumbled into SMF, and I am now a fan.</p>
<p>I wanted to move a few of the programs I run into SMF, one of the aforementioned awesome features.  SMF is Sun&#8217;s replacement init process, which takes a more active approach to services than the traditional &#8220;tell it to start and hope it does.&#8221; It, and all the other new <a href="http://upstart.ubuntu.com/">init</a> <a href="http://developer.apple.com/macosx/launchd.html">replacements</a> borrow a good bit from djb&#8217;s <a href="http://cr.yp.to/daemontools.html">daemontools</a>, which everyone seems to be realizing, ten years later, is actually a good idea.</p>
<p>SMF provides two primary benefits over traditional init script methods, in my mind, the first of which is process supervision. Process supervision means that when your app crashes, you don&#8217;t have to rely on monitoring scripts (or other people) to notice it&#8217;s gone, SMF notices immediately and attempts to restart the process. If it won&#8217;t stay started after a few tries, it&#8217;ll stop and switch the process to maintenance mode, meaning you get to fix it.</p>
<p>The second is its ability to break out instances of an application by essentially subclassing the main &#8220;default&#8221; instance and redefining configuration variables, such as which config file to read, where to keep the database, etc. This means you can, with a few commands, bring up another instance of apache for testing, or maybe a number of mongrels serving different apps, from the generic service definition.</p>
<p>Sun has a <a href="http://www.sun.com/software/solaris/howtoguides/smfmanifesthowto.jsp">pretty good how-to</a> online dealing with postgresql, which is helpful, but leaves out a few chunks. SMF expects you to provide it with start and stop methods, which is helpful if you just want to move a legacy service over to SMF, but some applications are simpler than that and work fine by just running them and sending them a kill signal when they need to go away. In this case, you can just give the command to launch the daemon as the start method, and fill the stop method with <code>:kill</code>. This will instruct SMF to send a kill signal to the process and children executed by the start method.  Incidentially, if the app reloads configuration when sent -HUP, you can fill in <code>:kill -HUP</code> as the refresh method. This isn&#8217;t explicitly spelled out in any documentation I&#8217;ve read, but it&#8217;s used in a few places in the manifests that ship with Solaris.</p>
<p>Below is a manifest I whipped up for mt-daapd, which scans and shares out all of my spiffy tunes so itunes can play &#8216;em.</p>
<pre>&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"&gt;
&lt;service_bundle type="manifest" name="mt-daapd"&gt;
    &lt;service name="network/mt-daapd" type="service" version="1"&gt;
        &lt;dependency name="network" grouping="require_all" restart_on="none" type="service"&gt;
            &lt;service_fmri value="svc:/milestone/network:default"/&gt;
        &lt;/dependency&gt;
        &lt;exec_method type="method" name="start" exec="/export/home/pjjw/opt/pkgs/mt-daapd/sbin/mt-daapd -y -c %{mt-daapd/conffile}" timeout_seconds="10" /&gt;
        &lt;exec_method type="method" name="refresh" exec=":kill -HUP" timeout_seconds="10" /&gt;
        &lt;exec_method type="method" name="stop" exec=":kill" timeout_seconds="10" /&gt;
        &lt;instance name="default" enabled="false"&gt;
            &lt;property_group name='config' type='application'&gt;
                &lt;propval name='conffile' type='astring' value='/export/home/pjjw/opt/pkgs/mt-daapd/etc/mt-daapd.conf' /&gt;
            &lt;/property_group&gt;
        &lt;/instance&gt;
        &lt;stability value="Evolving"/&gt;
        &lt;template&gt;
            &lt;common_name&gt;
                &lt;loctext xml:lang="C"&gt;Firefly Media Server&lt;/loctext&gt;
            &lt;/common_name&gt;
            &lt;documentation&gt;
                &lt;doc_link name="Firefly Media Server homepage" uri="http://fireflymediaserver.org"/&gt;
            &lt;/documentation&gt;
        &lt;/template&gt;
    &lt;/service&gt;
&lt;/service_bundle&gt;</pre>
<p>I run two instances of this app- one which shares out the music that i&#8217;ve sorted and tagged properly, and then another one that shares out stuff that&#8217;s just arrived into torrent directories or the like. Ignore the ridiculous location I&#8217;ve installed this app to and note the property group and properties. I&#8217;ve got two config files, one describing one configuration, and another describing the other. I can make the second instance from the first with the following commands:</p>
<pre>
svccfg -s network/mt-daapd add incoming
svccfg -s network/mt-daapd:incoming setprop config/conffile = astring: /export/home/pjjw/opt/pkgs/mt-daapd/etc/incoming.conf
</pre>
<p>..and there it is, a new instance of the server.</p>
<pre>
[00:28:05][pjjw@push:~]$ svcs mt-daapd
STATE          STIME    FMRI
online         Oct_17   svc:/network/mt-daapd:incoming
online         Oct_17   svc:/network/mt-daapd:default
</pre>
<p>I&#8217;d actually just been running this in screen for about 6 months and restarting it when it crashed. This is much nicer now.</p>
]]></content:encoded>
			<wfw:commentRss>http://shortbus.org/bloggin/2008/10/22/making-a-manifest-for-smf/feed/</wfw:commentRss>
		</item>
		<item>
		<title>how to un-shoot your foot</title>
		<link>http://shortbus.org/bloggin/2008/09/29/dm-mapper-how-to-un-shoot-your-foot/</link>
		<comments>http://shortbus.org/bloggin/2008/09/29/dm-mapper-how-to-un-shoot-your-foot/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 18:39:15 +0000</pubDate>
		<dc:creator>peter</dc:creator>
		
		<category><![CDATA[shortbus]]></category>

		<category><![CDATA[dm-mapper]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[san]]></category>

		<category><![CDATA[snapshot]]></category>

		<category><![CDATA[whoops]]></category>

		<guid isPermaLink="false">http://shortbus.org/bloggin/?p=12</guid>
		<description><![CDATA[Recently I shot myself in the foot pretty bad. We have a ~12TB data array that was set up as a raw LVM2 device- no partition table. There were some issues with one of the cluster members, so I went to rescue boot to attempt to correct it. Redhat&#8217;s rescue boot, in the name of [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I shot myself in the foot pretty bad. We have a ~12TB data array that was set up as a raw LVM2 device- no partition table. There were some issues with one of the cluster members, so I went to rescue boot to attempt to correct it. Redhat&#8217;s rescue boot, in the name of spreading democracy, attempts to put a partition table on anything that doesn&#8217;t have one already, and I fat-fingered the key that made this happen right over the top of our array. Whoops.</p>
<p>This isn&#8217;t impossible to recover from- the only thing that got overwritten was, for the most part, LVM data, and it so happens that the boundaries of the volumes is more or less known (25% each), so recovery should be possible just by re-writing correct (or near-correct) headers setting the boundaries in the right spot. Problem with this approach is that you get one shot, and it&#8217;s not like we have another 12TB sitting around that we can copy the data to. Here&#8217;s where dm-mapper came in to save my ass.<br />
<span id="more-12"></span></p>
<p>Using dm-mapper&#8217;s snapshot target, you can create a working copy of a large device that you want to test a few smallish changes to- like, for example, rewriting the partition table and fscking.</p>
<p>The snapshot target actually uses two separate device-mapper types, <code>snapshot-origin</code>, which is the device that you want to create the snapshot of, and <code>snapshot</code>, which becomes the device that you&#8217;ll be able to make your ephemeral changes to. The <code>snapshot</code> device requires a <code>snapshot-origin</code> device as well as a device to hold the written changes. For this, it&#8217;s easy to use a file-backed loopback device.</p>
<p>First, we set up the <code>snapshot-origin</code> device:</p>
<pre>DEVSIZE=`sudo /sbin/blockdev --getsize /dev/sdb`
sudo /sbin/dmsetup create rescue-base-real --table \
        "0 $DEVSIZE linear /dev/loop0 0"
sudo /sbin/dmsetup create rescue-base --table \
        "0 $DEVSIZE snapshot-origin <origin-device>"</pre>
<p>Next, we make a file as large as we expect the changes to be and create a loopback device for it:</p>
<pre>dd if=/dev/zero of=/tmp/backing-store bs=1048576 count=1024 # 1GB
# get name of first available loopback
BACKINGDEV=`sudo /sbin/losetup -f`
sudo /sbin/losetup -f /tmp/backing-store</pre>
<p>Now, finally, create the snapshot device:</p>
<pre>sudo /sbin/dmsetup create rescue-snap --table \
        "0 $DEVSIZE snapshot /dev/mapper/rescue-base $BACKINGDEV n 8"</pre>
<p>The last two arguments to the above command instruct dm-mapper that this is a non-persistent device, and to use a chunk size of 8 for copy-on-write operations.</p>
<p>Now you&#8217;ve got yourself a device you can play with that won&#8217;t cause any permanent changes if you guess the extents incorrectly, or if a fsck does the wrong thing. As an example, it took me about three tries to get the extents set up correctly for maximum data recovery. If I&#8217;d been working with the bare device, this wouldn&#8217;t have ended as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://shortbus.org/bloggin/2008/09/29/dm-mapper-how-to-un-shoot-your-foot/feed/</wfw:commentRss>
		</item>
		<item>
		<title>apple&#8217;s dirty little python secret</title>
		<link>http://shortbus.org/bloggin/2008/07/29/apples-dirty-little-python-secret/</link>
		<comments>http://shortbus.org/bloggin/2008/07/29/apples-dirty-little-python-secret/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 20:15:30 +0000</pubDate>
		<dc:creator>peter</dc:creator>
		
		<category><![CDATA[shortbus]]></category>

		<guid isPermaLink="false">http://shortbus.org/bloggin/?p=11</guid>
		<description><![CDATA[From man python on OS X 10.5 (and probably before):
INTERACTIVE INPUT EDITING AND HISTORY SUBSTITUTION
       The Python inteterpreter supports editing of the current input line and
       history substitution, similar to facilities found in the Korn shell and
       [...]]]></description>
			<content:encoded><![CDATA[<p>From <code>man python</code> on OS X 10.5 (and probably before):</p>
<pre>INTERACTIVE INPUT EDITING AND HISTORY SUBSTITUTION
       The Python inteterpreter supports editing of the current input line and
       history substitution, similar to facilities found in the Korn shell and
       the  GNU  Bash shell.  However, rather than being implemented using the
       GNU Readline library, this Python interpreter  uses  the BSD  EditLine
       library editline(3) with a GNU Readline emulation layer.

       The  readline  module  provides the access to the EditLine library, but
       there are a few major differences compared to a traditional implementa-
       tion  using  the  Readline  library.   The command language used in the
       preference files is that of EditLine, as described in editrc(5) and not
       that   used  by  the  Readline  library. This  also  means that  the
       parse_and_bind() routines uses EditLine commands.  And  the preference
       file itself is ~/.editrc instead of ~/.inputrc.

       For  example,  the rlcompleter module, which defines a completion func-
       tion for the  readline  modules,  works correctly  with the  EditLine
       libraries, but needs to be initialized somewhat differently:

              import rlcompleter
              import readline
              readline.parse_and_bind ("bind ^I rl_complete")

       For vi mode, one needs:

              readline.parse_and_bind ("bind -v")</pre>
<p>Well, that explains why Python doesn&#8217;t play nice with my readline stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://shortbus.org/bloggin/2008/07/29/apples-dirty-little-python-secret/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mission Accomplished&#8230; oh wait</title>
		<link>http://shortbus.org/bloggin/2008/01/21/mission-accomplished-oh-wait/</link>
		<comments>http://shortbus.org/bloggin/2008/01/21/mission-accomplished-oh-wait/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 05:35:48 +0000</pubDate>
		<dc:creator>peter</dc:creator>
		
		<category><![CDATA[shortbus]]></category>

		<category><![CDATA[airport express]]></category>

		<category><![CDATA[airtunes]]></category>

		<category><![CDATA[karma]]></category>

		<category><![CDATA[network]]></category>

		<category><![CDATA[openwrt]]></category>

		<category><![CDATA[wds]]></category>

		<guid isPermaLink="false">http://shortbus.org/bloggin/2008/01/21/mission-accomplished-oh-wait/</guid>
		<description><![CDATA[I was going to write something here about my successes in integrating Apple wireless products into a pre-existing OpenWRT-based wireless network, but it seems I declared victory a bit too early. I can&#8217;t get the thing to form a mesh network with my broadcom-based OpenWRT router. According to the Google, this is a failing on [...]]]></description>
			<content:encoded><![CDATA[<p>I was going to write something here about my successes in integrating Apple wireless products into a pre-existing OpenWRT-based wireless network, but it seems I declared victory a bit too early. I can&#8217;t get the thing to form a mesh network with my broadcom-based OpenWRT router. According to the Google, this is a failing on both sides- OpenWRT is currently unable to use WPA2 with WDS, and the AirPort can&#8217;t join an exclusively WPA1 WDS network. I could fall back to WEP, as that&#8217;d be enough to keep most people off my network, but it&#8217;s mostly a joke these days anyhow.</p>
<p>I&#8217;ve settled on naming my network &#8220;608lovesyou&#8221;, changing all my passwords on my machines, and opening up my LAN to the building. Here&#8217;s hoping there&#8217;s nobody malicious around (ha). Hopefully either Kamikaze will be finished soon or the OpenWRT people will fix the WDS problem (WDS is way out of my depth).</p>
<p>Also, Airtunes is totally rad.</p>
]]></content:encoded>
			<wfw:commentRss>http://shortbus.org/bloggin/2008/01/21/mission-accomplished-oh-wait/feed/</wfw:commentRss>
		</item>
		<item>
		<title>what have i done?</title>
		<link>http://shortbus.org/bloggin/2007/12/31/what-have-i-done/</link>
		<comments>http://shortbus.org/bloggin/2007/12/31/what-have-i-done/#comments</comments>
		<pubDate>Tue, 01 Jan 2008 00:09:31 +0000</pubDate>
		<dc:creator>peter</dc:creator>
		
		<category><![CDATA[shortbus]]></category>

		<guid isPermaLink="false">http://shortbus.org/bloggin/2007/12/31/what-have-i-done/</guid>
		<description><![CDATA[No way to deny my nerdiness now.
]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://gamercard.xbox.com/stampedes.card" scrolling="no" frameborder="0" height="140" width="204"></iframe><br \/>No way to deny my nerdiness now.</p>
]]></content:encoded>
			<wfw:commentRss>http://shortbus.org/bloggin/2007/12/31/what-have-i-done/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
