<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Phatness.com</title>
	
	<link>http://phatness.com</link>
	<description>- Still kickin</description>
	<lastBuildDate>Fri, 12 Mar 2010 17:13:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/phatness" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="phatness" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Decrease “Latency” on Grails Builds</title>
		<link>http://phatness.com/2010/02/decrease-latency-on-grails-builds/</link>
		<comments>http://phatness.com/2010/02/decrease-latency-on-grails-builds/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 14:56:37 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://phatness.com/?p=2125</guid>
		<description><![CDATA[This is a tip for those of you dealing with long build times, which for me, is anything greater than about 4 seconds  
The problem that those of us with NADD face is the second we are waiting for something to finish, we [alt&#124;cmd]+Tab to a browser and start reading slashdot, rotten tomatoes, daringfireball, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://xkcd.com/303/"><img class="alignright" src="http://imgs.xkcd.com/comics/compiling.png" border="0" alt="" /></a>This is a tip for those of you dealing with long build times, which for me, is anything greater than about 4 seconds <img src='http://phatness.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The problem that those of us with <a href="http://www.randsinrepose.com/archives/2003/07/10/nadd.html">NADD</a> face is the second we are waiting for something to finish, we [alt|cmd]+Tab to a browser and start reading slashdot, rotten tomatoes, daringfireball, or any of a million other sites.  Likely, you classify this &#8220;quick field trip&#8221; as multitasking and because you are so very good at multitasking (despite what all the <a href="http://en.wikipedia.org/wiki/Human_multitasking">experts say</a>), you disregard the fact that your build was probably finished 10 minutes ago.<br />
<span id="more-2125"></span><br />
Well, I finally came to grips with these facts:</p>
<p>- I cannot multitask.  I can only context switch.  And user-to-kernel-to-user is getting slower in my old age.<br />
- Half the time I&#8217;m looking at my browser, I&#8217;m flipping back to see if the build has finished.  Further exacerbating the context switch problem.<br />
- I cannot bring myself to firewall off my favorite, &#8220;industry news&#8221; sites.</p>
<p>So with that, I decided to fix what I could.  That is, decreasing my &#8220;response latency&#8221; for &#8220;asynchronous tasks.&#8221;  You&#8217;ll need to be running on a Mac.  But you&#8217;re a super leet programmer so I&#8217;m sure you already are.  OS X has a frickin&#8217; awesome text-to-speech capability.  Bundled along with that is a command line app: say.</p>
<p>Try it out, type at the terminal: say &#8220;Why didn&#8217;t I think of that?&#8221;</p>
<p>Now, for those of you who remember <a href="http://en.wikipedia.org/wiki/Dr._Sbaitso">Dr. Spaitso</a>, you probably just shit yourself at how great the default voice sounds.  (Though, if you are my wife, you are dully unimpressed.)</p>
<p>So I&#8217;m sure you see where I&#8217;m going with this.  Let&#8217;s get down to it.</p>
<p>Open up your GRAILS_PROJECT/scripts/Events.groovy file, add the following:</p>
<pre class="js">eventStatusFinal = { msg -&gt;

    String.metaClass.say = {
        ["osascript", "-e", "tell application \"iTunes\" to set sound volume to 30"].execute()
        sleep(300)
        "say \"${delegate}\"".execute().waitFor()
        ["osascript", "-e", "tell application \"iTunes\" to set sound volume to 100"].execute()
    }

    if(msg.startsWith("Server running.")) {
        "Application is running".say()
    } else {
        msg.say()
    }
}</pre>
<p>I made this a metaClass option originally because it came from a groovy bootstrap groovy script.  You could just as easily make it a local closure or method.</p>
<p>The gist is that every time an event completes, it will read aloud the status line.  But first, it turns down the music playing in itunes.  (It just so happens that I have iTunes turned all the way up and use the system volume to regulate.  If you don&#8217;t do that, you will probably have to adjust the volume values)</p>
<p>Pretty neat!  I actually use this in some fashion in all my projects now&#8230; maven, ant, even xcode.  It really helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://phatness.com/2010/02/decrease-latency-on-grails-builds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grails Newbie Mistakes &amp; Gotchas</title>
		<link>http://phatness.com/2010/02/grails-newbie-mistakes-gotchas/</link>
		<comments>http://phatness.com/2010/02/grails-newbie-mistakes-gotchas/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 17:41:53 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Grails Tips]]></category>

		<guid isPermaLink="false">http://phatness.com/?p=2106</guid>
		<description><![CDATA[Whew, Grails has some gotchas.  It is so great for so many reasons.  But WOW!  There are some time sinks tucked away for you to discover.  In the hope of helping others, here is a list of the ones that hit me.

Constraints!  HasErrors!
Never, EVER forget to add constraints to your [...]]]></description>
			<content:encoded><![CDATA[<p>Whew, Grails has some gotchas.  It is so great for so many reasons.  But WOW!  There are some time sinks tucked away for you to discover.  In the hope of helping others, here is a list of the ones that hit me.<br />
<span id="more-2106"></span></p>
<h2>Constraints!  HasErrors!</h2>
<p>Never, EVER forget to add constraints to your composited domain model at the same time you forget to check hasErrors after save.  Grails will not tell you when your domain.save() fails.  When in doubt, pass failOnError:true to your save() calls.</p>
<p>Where would this hit you?  Most of the time scaffolding takes care of your db operations.  But, it happened to me in several places.  When I was loading a default set of data in Bootstrap.groovy, I never saw my new objects showing up.  The other, more devious situation was when I was using the Nimble plugin and extending the User object Nimble provides with some dependent classes.  I kept getting the wicked &#8220;hibernate transient &#8211; must save&#8221; exception.  Lastly, most of the time you are wrapping your CRUD in services, you will need to watch out for this.</p>
<h2>Watch That Naming!</h2>
<p>Many times I&#8217;ll create a class manually in the appropriate bucket for what I want to do.  For example, instead of going through grails create-integration-test package.Class, I&#8217;ll just go create a new class under $GRAILS_APP/tests/integration/package.  I spent a good hour trying to figure out why my integration test was not being run.  And then I found it.  I named my test ClassNameTest.groovy.  When it should be ClassNameTest<strong>[s]</strong>.groovy!  Doh!</p>
<h2>Grails Interactive</h2>
<p>The second you have a few maven dependencies and/or plugin dependencies, it can take grails multiple seconds (On average, 3 for me) just to resolve the dependencies of your app.  This is a serious flaw in Ivy (the underlying dependency management grails uses).  Unfortunately, this is what we are stuck with.  Run grails interactive to speed things up.  The JVM starts up and keeps running after each command.  (The dependency checks go away, but things are still slow.)  Further, regardless of how high you specify max memory, it still fails with out of memory errors every few run-app cycles.  There must be a few leaks still laying around.</p>
<h2>File Uploads</h2>
<p>Something no one tells you and is found no where on the grails.org documentation is how to get the true filename of an uploaded file.  If you just do what the docs tell you via:</p>
<pre class="js">def uploadedFile = request.getFile("file")
uploadedFile.name</pre>
<p>the result is that the filename is &#8220;file&#8221;.  Yes, real fucking useful!</p>
<p>Use, instead:</p>
<pre class="js">def uploadedFile = request.getFile("file")
uploadedFile.originalFilename</pre>
<h2>Leveraging established Java codebase</h2>
<p>One of the best aspects of Groovy, in my eyes, is being able to leverage Java.  Grails goes further and allows you to specify remote maven artifacts your app depends on.  This is great.  Until you want to reuse Java domain objects.</p>
<p>You see, GORM doesn&#8217;t support mapping both Groovy and Java objects if either of those objects refer to each other.  So you can&#8217;t have a Groovy domain object extend a Java object.  You can&#8217;t have a Groovy domain object contain a Java domain object.  There is an issue open on this:</p>
<p><a href="http://jira.codehaus.org/browse/GRAILS-4996">http://jira.codehaus.org/browse/GRAILS-4996</a></p>
<p>I&#8217;m bringing this up here because this limitation definitely isn&#8217;t documented anywhere.  And I didn&#8217;t discover it until step 98 out of 100 in integrating my codebases.</p>
<p>Further, I found that GORM errors are a bit limited in some circumstances (this one).  If you hit a problem where GORM is throwing a cryptic message, and it is about a object in your hasMany map, try removing the hasMany and adding it as a single relationship.  The error message gets much more verbose.</p>
<p>(if hasMany, move it to a single to get a better error message from hibernate)</p>
<pre class="js">
class Tool {
	//static hasMany = [ widgets : Widget, rocks : com.acme.crud.Rock ]
	static hasMany = [ widgets : Widget ]
	Rock rock
	String name
</pre>
<h2>Never *ever* use reserved variables in UrlMappings.</h2>
<p>Wait, there are reserved variable names?  Yeah, that&#8217;s what I said!  Say you have a parameter your controller needs called action.  $action actually maps to the function in your controller that will be called.  So if you use this, suddenly, no request will get to your controller.  (Unless it just so happens the type you enter in the URL exists as a function.)  This happens even if you use the extended UrlMapping syntax where you can specify the action you want to use.  In my case:</p>
<pre class="js">
"/download/$id/$version/$preview/$action/$filename" {
			controller = "downloadController"
			action = "index"
			constraints {

			}
		}
</pre>
<p>On no, don&#8217;t do that!  Change $action to something else instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://phatness.com/2010/02/grails-newbie-mistakes-gotchas/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Use Test Files in Grails</title>
		<link>http://phatness.com/2010/02/grails-test-files/</link>
		<comments>http://phatness.com/2010/02/grails-test-files/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 16:29:38 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Grails Tips]]></category>

		<guid isPermaLink="false">http://phatness.com/?p=2099</guid>
		<description><![CDATA[I&#8217;m embarking, balls-out, on a new project using Grails.  I&#8217;ll be leveraging a significant portion of our Java codebase and the fact that I can do that,is just plain stellar.
It quickly came time to test out some of the integration.  The very first question was how to load resources for testing.  E.g., [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m embarking, balls-out, on a new project using Grails.  I&#8217;ll be leveraging a significant portion of our Java codebase and the fact that I can do that,is just plain stellar.</p>
<p>It quickly came time to test out some of the integration.  The very first question was how to load resources for testing.  E.g., I have a service that handles file uploads.  How do I pass it a test file?</p>
<p>The documentation isn&#8217;t straightforward on this.  In fact, I found the solution attached to a bug report for grails 1.1.  It&#8217;s pretty simple, once you pull in the spring packages:</p>
<pre class="js">
import org.springframework.core.io.ClassPathResource
import org.springframework.core.io.Resource
</pre>
<p>And then in your testXXX() function:</p>
<pre class="js">
Resource resource = new ClassPathResource("resources/crying-baby.jpg")
def file = resource.getFile()
assert file.exists()
</pre>
<p>And you are good to go.  Note the assert at the end to verify things are working.</p>
]]></content:encoded>
			<wfw:commentRss>http://phatness.com/2010/02/grails-test-files/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SMF: Solr</title>
		<link>http://phatness.com/2010/02/smf-solr/</link>
		<comments>http://phatness.com/2010/02/smf-solr/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 18:58:23 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[System Admin]]></category>
		<category><![CDATA[Linux To Solaris]]></category>

		<guid isPermaLink="false">http://phatness.com/?p=2092</guid>
		<description><![CDATA[Setting up Solr was a bit different then the others.  Solr&#8217;s distribution is multifaceted, containing multiple server examples, client code, as well as, a simple production ready server.  So let me start off with a few steps I took in setting up Solr.


Download and extract latest binary from solr website.
Within solr folder is [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up Solr was a bit different then the others.  Solr&#8217;s distribution is multifaceted, containing multiple server examples, client code, as well as, a simple production ready server.  So let me start off with a few steps I took in setting up Solr.<br />
<span id="more-2092"></span></p>
<ol>
<li>Download and extract latest binary from solr website.</li>
<li>Within solr folder is examples/</li>
<li>Remove example-DIH/</li>
<li>Remove exampledocs/</li>
<li>Create directory /opt/local/share/solr-VERSION (solr-1.4 at time of this writing)</li>
<li>Copy contents of examples to /opt/local/share/solr-VERSION</li>
<li>Create a symlink /opt/local/share/solr-VERSION -&gt; solr</li>
</ol>
<p>And here is the SMF:</p>
<pre class="html">&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='Solr'&gt;

&lt;service
	name='network/solr'
	type='service'
	version='1'&gt;

	&lt;create_default_instance enabled='false'/&gt;
    &lt;single_instance/&gt;

	&lt;dependency name='fs'
		grouping='require_all'
		restart_on='none'
		type='service'&gt;
		&lt;service_fmri
			value='svc:/system/filesystem/local'/&gt;
    &lt;/dependency&gt;

    &lt;dependency name='net'
		grouping='require_all'
		restart_on='none'
		type='service'&gt;
		&lt;service_fmri value='svc:/network/loopback'/&gt;
    &lt;/dependency&gt;

    &lt;dependent name='solr_multi-user'
	 	grouping='optional_all'
		restart_on='none'&gt;
		&lt;service_fmri value='svc:/milestone/multi-user'/&gt;
    &lt;/dependent&gt;

    &lt;exec_method
		name='start'
		type='method'
		exec='/opt/local/lib/svc/method/svc-solr'
		timeout_seconds='60'&gt;

		&lt;method_context working_directory='/opt/local/share/solr'&gt;
        	&lt;method_credential user='root' group='root' /&gt;
      	&lt;/method_context&gt;
    &lt;/exec_method&gt;

    &lt;exec_method
		name='stop'
		type='method'
		exec=':kill'
		timeout_seconds='60'&gt;
    &lt;/exec_method&gt;

	&lt;template&gt;
		&lt;common_name&gt;
			&lt;loctext xml:lang='C'&gt;
				solr
			&lt;/loctext&gt;
		&lt;/common_name&gt;
	&lt;/template&gt;

&lt;/service&gt;
&lt;/service_bundle&gt;</pre>
<p>And the very short script it calls to start Solr:</p>
<p>svc-solr:</p>
<pre class="shell">#!/bin/sh                                                                                 

nohup java -Dsolr.data.dir=/opt/local/share/solr/data -jar start.jar &amp;</pre>
<p>That&#8217;s about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://phatness.com/2010/02/smf-solr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Troubleshooting SMF Service Startup</title>
		<link>http://phatness.com/2010/01/troubleshooting-smf-service-startup/</link>
		<comments>http://phatness.com/2010/01/troubleshooting-smf-service-startup/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 20:18:46 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[System Admin]]></category>
		<category><![CDATA[Linux To Solaris]]></category>

		<guid isPermaLink="false">http://phatness.com/?p=2059</guid>
		<description><![CDATA[As I was working on my SMF scripts for the migration from Linux, I found some fancy ways to trace what was happening with a service that failed to start with new configuration.
There is a command called truss which allows you to follow along as something is being executed.  See: man truss.
What I found [...]]]></description>
			<content:encoded><![CDATA[<p>As I was working on my SMF scripts for the migration from Linux, I found some fancy ways to trace what was happening with a service that failed to start with new configuration.</p>
<p>There is a command called truss which allows you to follow along as something is being executed.  See: man truss.</p>
<p>What I found really cool is that you can modify your existing SMF script from the command line.  No need to make changes to xml and then reimport.</p>
<p>So back to the tip, if a service isn&#8217;t starting and you have eliminated all of the other possibilities with configuration, you need to see what the service script is doing.  In my case, I was having a hell of a time with Red5.  So here is what you can do:<br />
<span id="more-2059"></span><br />
Use to find what is the start method.  In this case, /opt/local/share/red5/red5.sh:</p>
<pre class="shell">[user@host ~]$ svcprop -p start/exec red5</pre>
<p>Install a new start method:</p>
<pre class="shell">[user@host ~]$ svccfg -s red5 setprop 'start/exec = “truss -f -a -o /tmp/truss.out red5.sh”'</pre>
<p>Now try to start the service again:</p>
<pre class="shell">[user@host ~]$ svcadm clear red5
[user@host ~]$ svcadm enable red5</pre>
<p>Notice the clear command!  That tripped me up several times when you would enable the service, but no warning was thrown about it being in maintenance mode.</p>
<p>Now go check the contents of /tmp truss.out to see what happened.  My problem for red5 is that I was using a relative path to red5.sh.  I specified in the environment that the working directory was /opt/local/share/red5.  However, it appears that you still must specify an absolute path to the script.</p>
]]></content:encoded>
			<wfw:commentRss>http://phatness.com/2010/01/troubleshooting-smf-service-startup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SMF: Red5</title>
		<link>http://phatness.com/2010/01/smf-red5/</link>
		<comments>http://phatness.com/2010/01/smf-red5/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 15:26:25 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[System Admin]]></category>
		<category><![CDATA[Linux To Solaris]]></category>

		<guid isPermaLink="false">http://phatness.com/?p=2046</guid>
		<description><![CDATA[Red5 is the open source answer to Adobe&#8217;s Flash Streaming Server.  I use it not for streaming, but for recording audio and video from a user&#8217;s web browser.  Yeah, that is a really cool feature if you have the need for it.
It turns out that the Red5 team actually created an SMF configuration. [...]]]></description>
			<content:encoded><![CDATA[<p>Red5 is the open source answer to Adobe&#8217;s Flash Streaming Server.  I use it not for streaming, but for recording audio and video from a user&#8217;s web browser.  Yeah, that is a really cool feature if you have the need for it.</p>
<p>It turns out that the Red5 team actually created an SMF configuration.  However, you have to download the source to get to it.  I was half way through my own before I saw the change entry on the Red5 commit mailing list.  However, it used some funky paths.  I took this and fixed it for my Joyent specific installation.<br />
<span id="more-2046"></span><br />
First, download the tar of red5 from red5.org.  Extract the contents to /opt/local/share/red5-VERSION.  Create a symlink from /opt/local/share/red5 to red5-VERSION.</p>
<p>Here is the SMF config:</p>
<pre class="html">
&lt;?xml version=&#x27;1.0&#x27;?&gt;
&lt;!DOCTYPE service_bundle SYSTEM
&#x27;/usr/share/lib/xml/dtd/service_bundle.dtd.1&#x27;&gt;
&lt;!--
Solaris Service Management Facility for Red5

The idea for this file came from a post by Paul Oswald
URL: http://pauloswald.com/article/29/hudson-solaris-smf-manifest
Modified for use with Red5 by Paul Gregoire (mondain@gmail.com)
Modified for Red5 on Joyent accelerators by The Dude

More info: 

http://www.sun.com/bigadmin/content/selfheal/smf-quickstart.jsp

http://www.sun.com/bigadmin/content/selfheal/sdev_intro.html

--&gt;
&lt;service_bundle type=&quot;manifest&quot; name=&quot;Red5&quot;&gt;

&lt;service
	name=&quot;application/red5&quot;
	type=&quot;service&quot;
	version=&quot;1&quot;&gt;

	&lt;create_default_instance enabled=&quot;false&quot; /&gt;
	&lt;single_instance /&gt;

	&lt;dependency name=&#x27;fs&#x27;
		grouping=&#x27;require_all&#x27;
		restart_on=&#x27;none&#x27;
		type=&#x27;service&#x27;&gt;
		&lt;service_fmri
			value=&#x27;svc:/system/filesystem/local&#x27;/&gt;
    &lt;/dependency&gt;

    &lt;dependency name=&#x27;net&#x27;
		grouping=&#x27;require_all&#x27;
		restart_on=&#x27;none&#x27;
		type=&#x27;service&#x27;&gt;
		&lt;service_fmri value=&#x27;svc:/network/loopback&#x27;/&gt;
    &lt;/dependency&gt;

    &lt;dependent name=&#x27;solr_multi-user&#x27;
 		grouping=&#x27;optional_all&#x27;
		restart_on=&#x27;none&#x27;&gt;
		&lt;service_fmri value=&#x27;svc:/milestone/multi-user&#x27;/&gt;
    &lt;/dependent&gt;

	&lt;method_context working_directory=&#x27;/opt/local/share/red5&#x27;&gt;
		&lt;method_credential user=&#x27;red5&#x27; group=&#x27;red5&#x27; /&gt;
	&lt;/method_context&gt;

	&lt;exec_method
		type=&quot;method&quot;
		name=&quot;start&quot;
	    exec=&quot;/opt/local/share/red5/red5.sh&quot;
	    timeout_seconds=&quot;0&quot;&gt;
	&lt;/exec_method&gt;

	&lt;exec_method
		type=&quot;method&quot;
		name=&quot;stop&quot;
	    exec=&quot;:kill -TERM&quot;
	    timeout_seconds=&quot;30&quot;/&gt;

	&lt;!-- Red5 runs as a single child process so we want Wait mode--&gt;
	&lt;property_group name=&#x27;startd&#x27; type=&#x27;framework&#x27;&gt;
		&lt;propval name=&#x27;duration&#x27; type=&#x27;astring&#x27; value=&#x27;child&#x27; /&gt;
	&lt;/property_group&gt;

	&lt;stability value=&quot;Unstable&quot; /&gt;

	&lt;template&gt;
		&lt;common_name&gt;
			&lt;loctext xml:lang=&#x27;C&#x27;&gt;
				red5
			&lt;/loctext&gt;
		&lt;/common_name&gt;
		&lt;documentation&gt;
			&lt;doc_link name=&#x27;red5.org&#x27; uri=&#x27;http://red5.org/&#x27; /&gt;
		&lt;/documentation&gt;
	&lt;/template&gt;
&lt;/service&gt;
&lt;/service_bundle&gt;
</pre>
<p>This guy is a bit simpler as it doesn&#8217;t require a script to handle starting or stopping.  It assumes red5 is installed under /opt/local/share/red5.  The same applies as before for installing it:</p>
<pre class="shell">
sudo mv red5.xml /var/svc/manifest/network/
</pre>
<p>Then run the following (likely with sudo):</p>
<pre class="shell">
chown root:sys /var/svc/manifest/network/red5.xml
chmod 444 /var/svc/manifest/network/red5.xml
svccfg import /var/svc/manifest/network/red5.xml
</pre>
<p>You&#8217;ll need to have a user and group added named red5.</p>
<p>Now, time to go watch Avatar for the 5th time.  Who am I kidding?  I have to go burp Alec.</p>
]]></content:encoded>
			<wfw:commentRss>http://phatness.com/2010/01/smf-red5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SMF: Tomcat</title>
		<link>http://phatness.com/2010/01/smf-tomcat/</link>
		<comments>http://phatness.com/2010/01/smf-tomcat/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 16:10:18 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[System Admin]]></category>
		<category><![CDATA[Linux To Solaris]]></category>

		<guid isPermaLink="false">http://phatness.com/?p=2026</guid>
		<description><![CDATA[For my Tomcat SMF setup, I have two files.  One, the configuration for SMF.  The second is the script used to start and restart tomcat.  (My stop is simply a kill.  Unfortunately, there are a few threads that aren&#8217;t shutting down properly.)

First, the configuration:

&#60;?xml version=&#x27;1.0&#x27;?&#62;
&#60;!DOCTYPE service_bundle SYSTEM
&#x27;/usr/share/lib/xml/dtd/service_bundle.dtd.1&#x27;&#62;

&#60;service_bundle type=&#x27;manifest&#x27; name=&#x27;Tomcat&#x27;&#62;

&#60;service
	name=&#x27;network/tomcat&#x27;
	type=&#x27;service&#x27;
	version=&#x27;1&#x27;&#62;

	&#60;create_default_instance enabled=&#x27;false&#x27; /&#62;
	&#60;single_instance /&#62;

	&#60;dependency name=&#x27;fs&#x27;
		grouping=&#x27;require_all&#x27;
		restart_on=&#x27;none&#x27;
		type=&#x27;service&#x27;&#62;
		&#60;service_fmri [...]]]></description>
			<content:encoded><![CDATA[<p>For my Tomcat SMF setup, I have two files.  One, the configuration for SMF.  The second is the script used to start and restart tomcat.  (My stop is simply a kill.  Unfortunately, there are a few threads that aren&#8217;t shutting down properly.)<br />
<span id="more-2026"></span><br />
First, the configuration:</p>
<pre class="html">
&lt;?xml version=&#x27;1.0&#x27;?&gt;
&lt;!DOCTYPE service_bundle SYSTEM
&#x27;/usr/share/lib/xml/dtd/service_bundle.dtd.1&#x27;&gt;

&lt;service_bundle type=&#x27;manifest&#x27; name=&#x27;Tomcat&#x27;&gt;

&lt;service
	name=&#x27;network/tomcat&#x27;
	type=&#x27;service&#x27;
	version=&#x27;1&#x27;&gt;

	&lt;create_default_instance enabled=&#x27;false&#x27; /&gt;
	&lt;single_instance /&gt;

	&lt;dependency name=&#x27;fs&#x27;
		grouping=&#x27;require_all&#x27;
		restart_on=&#x27;none&#x27;
		type=&#x27;service&#x27;&gt;
		&lt;service_fmri value=&#x27;svc:/system/filesystem/local&#x27; /&gt;
	&lt;/dependency&gt;

	&lt;dependency name=&#x27;net&#x27;
		grouping=&#x27;require_all&#x27;
		restart_on=&#x27;none&#x27;
		type=&#x27;service&#x27;&gt;
		&lt;service_fmri value=&#x27;svc:/network/loopback&#x27; /&gt;
	&lt;/dependency&gt;

	&lt;exec_method
		type=&#x27;method&#x27;
		name=&#x27;start&#x27;
		exec=&#x27;/opt/local/lib/svc/method/svc-tomcat start&#x27;
		timeout_seconds=&#x27;-1&#x27;&gt;
		&lt;method_context&gt;
			&lt;method_credential user=&#x27;root&#x27; group=&#x27;root&#x27; /&gt;
		&lt;/method_context&gt;
	&lt;/exec_method&gt;

	&lt;exec_method
		type=&#x27;method&#x27;
		name=&#x27;stop&#x27;
		exec=&#x27;:kill&#x27;
		timeout_seconds=&#x27;-1&#x27;&gt;
	&lt;/exec_method&gt;

	&lt;exec_method
		type=&#x27;method&#x27;
		name=&#x27;restart&#x27;
		exec=&#x27;/opt/local/lib/svc/method/svc-tomcat restart&#x27;
		timeout_seconds=&#x27;-1&#x27;&gt;
	&lt;/exec_method&gt;

	&lt;stability value=&#x27;Unstable&#x27; /&gt;

	&lt;template&gt;
		&lt;common_name&gt;
			&lt;loctext xml:lang=&#x27;C&#x27;&gt;
				tomcat
			&lt;/loctext&gt;
		&lt;/common_name&gt;
	&lt;/template&gt;
&lt;/service&gt;
&lt;/service_bundle&gt;
</pre>
<p>The shell script looks like:</p>
<pre class="shell">
#!/usr/bin/sh

. /lib/svc/share/smf_include.sh

case $1 in
'start')
	echo "starting tomcat..."
	/opt/local/share/tomcat/bin/startup.sh &#038; >/dev/null 2> /dev/null
	;;

'stop')
	echo "stopping tomcat..."
	/opt/local/share/tomcat/bin/shutdown.sh &#038;
;;

'restart')
	stop
# give stuff some time to stop before we restart
	sleep 25
	start
	;;
*)
	echo "Usage: $0 { start | stop | restart }"
	exit 1
	;;
esac
</pre>
<p>Put tomcat.xml in /var/svc/manifest/network/tomcat.xml<br />
Put svc-tomcat in /opt/local/lib/svc/method/svc-tomcat</p>
<p>I had to create the local svc/method directory so before I could put svc-tomcat where it needed to be.</p>
<p>Then run the following (likely with sudo):</p>
<pre class="shell">
chown root:bin /opt/local/lib/svc/method/svc-tomcat
chmod 555 /opt/local/lib/svc/method/svc-tomcat
chown root:sys /var/svc/manifest/network/tomcat.xml
chmod 444 /var/svc/manifest/network/tomcat.xml
svccfg import /var/svc/manifest/network/tomcat.xml
</pre>
<p>That&#8217;s it.  You can check on the service with:</p>
<pre class="shell">
[user@host ~]$ svcs -xv tomcat
</pre>
<p>And start it via:</p>
<pre class="shell">
[user@host ~]$ svcadm enable tomcat
</pre>
]]></content:encoded>
			<wfw:commentRss>http://phatness.com/2010/01/smf-tomcat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google in China?</title>
		<link>http://phatness.com/2010/01/google-in-china/</link>
		<comments>http://phatness.com/2010/01/google-in-china/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 17:07:34 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Society]]></category>

		<guid isPermaLink="false">http://phatness.com/?p=2069</guid>
		<description><![CDATA[Google corporate infrastructure was hacked in mid-December.  It looks like not that much information was stolen.
However, it has said that they will no longer be censoring search results for users in China because the attach originated from the Chinese government:
We have decided we are no longer willing to continue censoring our results on Google.cn, [...]]]></description>
			<content:encoded><![CDATA[<p>Google corporate infrastructure was hacked in mid-December.  It looks like not that much information was stolen.</p>
<p>However, it has said that they will no longer be censoring search results for users in China because the attach originated from the Chinese government:</p>
<blockquote><p>We have decided we are no longer willing to continue censoring our results on Google.cn, and so over the next few weeks we will be discussing with the Chinese government the basis on which we could operate an unfiltered search engine within the law, if at all.</p></blockquote>
<p>How awesome is that?  </p>
<p>What that tells me though is that google.cn will stop operating in the next few months.  We all know that there is no way in hell the Chinese government will allow google to provide results, uncensored.</p>
<p>Check it out: http://googleblog.blogspot.com/2010/01/new-approach-to-china.html</p>
]]></content:encoded>
			<wfw:commentRss>http://phatness.com/2010/01/google-in-china/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why is SSH so Slow?</title>
		<link>http://phatness.com/2010/01/why-is-ssh-so-slow/</link>
		<comments>http://phatness.com/2010/01/why-is-ssh-so-slow/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 13:06:26 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[System Admin]]></category>

		<guid isPermaLink="false">http://phatness.com/?p=2021</guid>
		<description><![CDATA[I was having a horrendous time logging into one particular Linux server.  It would take anywhere from 20 seconds to a minute to let me log in.
Turns out, there are two sshd config settings you should pay attention to:
VerifyReverseMapping and GssAuthentication
The latter only really helps if you are connecting from a Mac (like me).  VerifyReverseMapping will [...]]]></description>
			<content:encoded><![CDATA[<p>I was having a horrendous time logging into one particular Linux server.  It would take anywhere from 20 seconds to a minute to let me log in.</p>
<p>Turns out, there are two sshd config settings you should pay attention to:</p>
<p><strong>VerifyReverseMapping</strong> and <strong>GssAuthentication</strong></p>
<p>The latter only really helps if you are connecting from a Mac (like me).  VerifyReverseMapping will tell the server to look up the host name for client IPs, and if the IP you&#8217;re SSH&#8217;ing from doesn&#8217;t have a reverse DNS entry, this will result in a DNS timeout.  (The source of most of the delay in logging in.)</p>
<p>So open up your sshd config file: /etc/ssh/sshd_config</p>
<p>Remove VerifyReverseMapping, if it exists.  The default value for it is no.  If you don&#8217;t see it, this isn&#8217;t the source of your problem.</p>
<p>Remove GssAuthentication, if it exists.  It also, defaults to no.</p>
]]></content:encoded>
			<wfw:commentRss>http://phatness.com/2010/01/why-is-ssh-so-slow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solaris Service Management Facility</title>
		<link>http://phatness.com/2010/01/solaris-smf/</link>
		<comments>http://phatness.com/2010/01/solaris-smf/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 14:21:37 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[System Admin]]></category>
		<category><![CDATA[Linux To Solaris]]></category>

		<guid isPermaLink="false">http://phatness.com/?p=2006</guid>
		<description><![CDATA[Leading in with my post on switching from Linux to OpenSolaris, there are quite a few things I am in love with on OpenSolaris.
Since my first real world exposure to OpenSolaris is the process of migrating web applications away from Linux, the first thing I really had to get familiar with is the Service Management [...]]]></description>
			<content:encoded><![CDATA[<p>Leading in with my <a href="http://phatness.com/2010/01/linux-to-solaris/">post</a> on switching from Linux to OpenSolaris, there are quite a few things I am in love with on OpenSolaris.</p>
<p>Since my first real world exposure to OpenSolaris is the process of migrating web applications away from Linux, the first thing I really had to get familiar with is the Service Management Facility framework.  SMF for short.  <a href="http://www.sun.com/bigadmin/content/selfheal/" target="_blank">SMF</a> is the Solaris equivalent of UNIX/Linux init.d, Apple’s <a href="http://developer.apple.com/macosx/launchd.html" target="_blank">launchd</a>, or Windows services.</p>
<p>I&#8217;m coming from a decade long Linux background so let me compare and contrast init.d and SMF.<span id="more-2006"></span></p>
<ul>
<li>Like init.d, SMF services are first-class objects that you can query for status and start and stop.</li>
</ul>
<ul>
<li>Unlike init.d, if SMF services encounter an error that caused a failure of the service, SMF will AUTOMATICALLY RESTART the service!  However, it isn&#8217;t a blind restart.  If the service fails after X number of restarts, SMF will disable the service until manual intervention happens.</li>
</ul>
<ul>
<li>SMF provides a facility to see why a service is not running or stats on running.  The command svcs -x (I remember using <strong>S</strong>er<strong>V</strong>i<strong>C</strong>e <strong>S</strong>tatus):</li>
</ul>
<pre>[user@host ~]$ svcs -x tomcat
svc:/network/tomcat:default (tomcat)
 State: online since January  6, 2010  7:54:02 PM GMT
   See: /var/svc/log/network-tomcat:default.log
Impact: None.</pre>
<p>Or for a disabled service:</p>
<pre>[user@host ~]$ svcs -x tomcat
svc:/network/tomcat:default (tomcat)
 State: disabled since January  7, 2010  3:07:47 PM GMT
Reason: Disabled by an administrator.
   See: http://sun.com/msg/SMF-8000-05
   See: /var/svc/log/network-tomcat:default.log
Impact: This service is not running.</pre>
<p>Notice the Reason field.  Awesome!</p>
<ul>
<li>Like init.d, SMF provides start/stop/restart actions on a service.  However, the equivalent actions are named differently: enable/disable/restart.  Use svcadm enable tomcat to start a service.</li>
</ul>
<ul>
<li>Unlike init.d, SMF provides the ability for non root users to start and stop services!</li>
</ul>
<ul>
<li>Like init.d, SMF provides a way for services to fire up in a dependent order.</li>
</ul>
<ul>
<li>Unlike init.d, SMF provides a way to declare those dependencies rather than relying on an integer value to start in a certain order.  On top of being much clearer to admin, this allows systems to boot up faster by starting services in parallel.</li>
</ul>
<ul>
<li>Unlike init.d, SMF provides a logging framework that is transparent to the service.  I&#8217;ve found in my use, this is both good and bad.  My SOLR SMF config is moving the SOLR log output from the SOLR install directory to the SMF log directory.  I&#8217;ll get to that in another post.</li>
</ul>
<ul>
<li>Unlike init.d, SMF is much more complicated then adding a simple shell script to the init.d folder.  The learning curve is a bit longer/higher than init.d.</li>
</ul>
<p>This list is certainly not comprehensive.  You can find out more at Sun&#8217;s BigAdmin site.  <a href="http://www.sun.com/bigadmin/content/selfheal/smf-quickstart.jsp" target="_blank">Solaris Service Management Facility &#8211; Quickstart Guide</a></p>
<p>Up next, a SMF config for Tomcat&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://phatness.com/2010/01/solaris-smf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
