<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Liquid Rhymes &#187; Mediawiki</title>
	<atom:link href="http://www.liquidrhymes.com/category/development/mediawiki-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.liquidrhymes.com</link>
	<description>Musings of Simon Mosk-Aoyama</description>
	<lastBuildDate>Mon, 25 Apr 2011 17:17:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Getting Sphinx Search Running with MediaWiki on OSX</title>
		<link>http://www.liquidrhymes.com/2010/06/16/getting-sphinx-search-running-with-mediawiki-on-osx/</link>
		<comments>http://www.liquidrhymes.com/2010/06/16/getting-sphinx-search-running-with-mediawiki-on-osx/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 18:25:41 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Mediawiki]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[mediawiki]]></category>

		<guid isPermaLink="false">http://liquidrhymes.com/?p=1</guid>
		<description><![CDATA[I had a bit of an issue getting <a href="http://sphinxsearch.com/">Sphinx Search</a> running with MediaWiki in OSX as I found creating a plist to be a harder problem than I anticipated. I followed the standard <a href="http://www.mediawiki.org/wiki/Extension:SphinxSearch#Installation_Instructions">Mediawiki</a> installation instructions until I got to the point of setting up the daemon.]]></description>
			<content:encoded><![CDATA[<p>I had a bit of an issue getting <a href="http://sphinxsearch.com/">Sphinx Search</a> running with MediaWiki in OSX as I found creating a plist to be a harder problem than I anticipated. I followed the standard <a href="http://www.mediawiki.org/wiki/Extension:SphinxSearch#Installation_Instructions">Mediawiki</a> installation instructions until I got to the point of setting up the daemon.</p>
<p>In OS X it turns out the way to get a daemon to run is to run using <a href="http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/Daemons.html">launchd</a>. The process to get one of these to run is to create an XML file in <code>/Library/LaunchDaemons</code> (there OS X has it&#8217;s own plist files in <code>/Library/LaunchDaemons</code>) and run <a href="http://www.google.com/search?sourceid=chrome&amp;ie=UTF-8&amp;q=launchctl"><code>launchctl</code></a> to start the daemon.</p>
<p>I created my own daemon file for Sphinx, sphinx, in /Library/LaunchDaemons:</p>
<p>[xml]<br />
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br />
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot;<br />
        &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;<br />
&lt;plist version=&quot;1.0&quot;&gt;<br />
&lt;dict&gt;<br />
        &lt;key&gt;Label&lt;/key&gt;<br />
        &lt;string&gt;org.search.sphinx&lt;/string&gt;<br />
        &lt;key&gt;UserName&lt;/key&gt;<br />
        &lt;string&gt;simon&lt;/string&gt;<br />
        &lt;key&gt;ProgramArguments&lt;/key&gt;<br />
        &lt;array&gt;<br />
                &lt;string&gt;/usr/local/bin/searchd&lt;/string&gt;<br />
                &lt;string&gt;&#8211;config&lt;/string&gt;<br />
                &lt;string&gt;/Users/simon/source/mediawiki/wikinutrition/private/sphinx.conf&lt;/string&gt;<br />
        &lt;/array&gt;<br />
        &lt;key&gt;StandardOutPath&lt;/key&gt;<br />
        &lt;string&gt;/var/log/sphinx/sphinx-startup.log&lt;/string&gt;<br />
        &lt;key&gt;KeepAlive&lt;/key&gt;<br />
        &lt;true/&gt;<br />
        &lt;key&gt;debug&lt;/key&gt;<br />
        &lt;true/&gt;<br />
        &lt;key&gt;RunAtLoad&lt;/key&gt;<br />
        &lt;true/&gt;<br />
&lt;/dict&gt;<br />
&lt;/plist&gt;<br />
[/xml]<br />
You can see I am running the daemon as myself using the <b>UserName</b> key.</p>
<p>Unfortunately when I went to start this using <code>launchctl load -w /Library/LaunchDaemons/sphinx</code> nothing appeared to happen. No error message, no nothing. When I turned the debug setting on (by adding &lt;key&amp;gtdebug&lt;/key&gt;&lt;true/&gt;), however, I noticed in <code>/var/log/system.log</code> a number of these messages:</p>
<p><code><br />
Jun 15 17:13:26 simon-mosk-aoyamas-computer-6 com.apple.launchd[1] (org.search.sphinx): Throttling respawn: Will start in 10 seconds<br />
</code></p>
<p>Googling this led to this <a href="http://developer.apple.com/macosx/launchd.html">discovery from Apple</a>:</p>
<blockquote><p>
Jobs run from launchd should not duplicate launchd functionality; for instance, they should not use chroot(2). Furthermore, they should not do the things normally required of daemon processes, such as detaching from the terminal they are initially attached to. The only things that are strictly prohibited, however, are fork()/exit() combinations (including indirect methods, such as the daemon(3) library call). A server which attempts to run itself as a daemon in this way will seem to have finished running, potentially leading to launchd respawning it, or disabling the service. As launchd does not get stalled waiting for a child that hasn&#8217;t yet exited, it&#8217;s not necessary to try to prevent it.
</p></blockquote>
<p>Bingo &#8211; here is the problem &#8211; Sphinx&#8217;s searchd starts and forks as it&#8217;s a traditional daemon. Thankfully it has a <code>--console</code> option which does not fork, so adding  <code>--console</code> to the plist file (inside the &lt;ProgramArguments&gt; array) had me up and running!</p>
<p>The final file:<br />
[xml]<br />
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br />
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot;<br />
        &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;<br />
&lt;plist version=&quot;1.0&quot;&gt;<br />
&lt;dict&gt;<br />
        &lt;key&gt;Label&lt;/key&gt;<br />
        &lt;string&gt;org.search.sphinx&lt;/string&gt;<br />
        &lt;key&gt;UserName&lt;/key&gt;<br />
        &lt;string&gt;simon&lt;/string&gt;<br />
        &lt;key&gt;ProgramArguments&lt;/key&gt;<br />
        &lt;array&gt;<br />
                &lt;string&gt;/usr/local/bin/searchd&lt;/string&gt;<br />
                &lt;string&gt;&#8211;config&lt;/string&gt;<br />
                &lt;string&gt;/Users/simon/source/mediawiki/wikinutrition/private/sphinx.conf&lt;/string&gt;<br />
                &lt;string&gt;&#8211;console&lt;/string&gt;<br />
        &lt;/array&gt;<br />
        &lt;key&gt;StandardOutPath&lt;/key&gt;<br />
        &lt;string&gt;/var/log/sphinx/sphinx-startup.log&lt;/string&gt;<br />
        &lt;key&gt;KeepAlive&lt;/key&gt;<br />
        &lt;true/&gt;<br />
        &lt;key&gt;debug&lt;/key&gt;<br />
        &lt;true/&gt;<br />
        &lt;key&gt;RunAtLoad&lt;/key&gt;<br />
        &lt;true/&gt;<br />
&lt;/dict&gt;<br />
&lt;/plist&gt;<br />
[/xml]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liquidrhymes.com/2010/06/16/getting-sphinx-search-running-with-mediawiki-on-osx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

