<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Nick Sieger: Blog Setup</title>
  <id>tag:blog.nicksieger.com,2005:Typo</id>
  <generator uri="http://www.typosphere.org" version="4.0">Typo</generator>
  <link rel="self" type="application/atom+xml" href="http://blog.nicksieger.com/xml/atom10/article/431/feed.xml"/>
  <link rel="alternate" type="text/html" href="http://blog.nicksieger.com/articles/2008/07/10/blog-setup"/>
  <updated>2008-07-23T20:20:59+00:00</updated>
  <entry>
    <author>
      <name>Nick</name>
    </author>
    <id>urn:uuid:962842f5-8d1a-4671-966b-fb59b6e7b983</id>
    <published>2008-07-23T20:20:59+00:00</published>
    <updated>2008-07-23T20:20:59+00:00</updated>
    <title>Comment on Blog Setup by Nick</title>
    <link rel="alternate" type="text/html" href="http://blog.nicksieger.com/articles/2008/07/10/blog-setup#comment-450"/>
    <content type="html">&lt;p&gt;ivar: we typically just include the &lt;code&gt;db&lt;/code&gt; directory and rakefile in our war file and do these tasks on the server with a jruby installation&amp;#46; I haven&amp;#8217;t really seen any best practices in this area yet&amp;#46; There&amp;#8217;s been talk of having the application run its own migrations at application startup, but that seems a little dangerous&amp;#46;&amp;#46;&amp;#46;&lt;/p&gt;</content>
  </entry>
  <entry>
    <author>
      <name>ivar</name>
    </author>
    <id>urn:uuid:e87181c8-34a6-434a-b72d-fff4b92cc7a2</id>
    <published>2008-07-23T17:45:39+00:00</published>
    <updated>2008-07-23T17:45:40+00:00</updated>
    <title>Comment on Blog Setup by ivar</title>
    <link rel="alternate" type="text/html" href="http://blog.nicksieger.com/articles/2008/07/10/blog-setup#comment-449"/>
    <content type="html">&lt;p&gt;Having a simple recipe like this is very handy &amp;#45; thanks ! My next question is if you have a suggested method for handling migrations ? (or rake tasks in general)&lt;/p&gt;</content>
  </entry>
  <entry>
    <author>
      <name>Song</name>
    </author>
    <id>urn:uuid:3b6c2da4-4cc6-4397-b5c7-5bd52e6dd85a</id>
    <published>2008-07-14T07:39:44+00:00</published>
    <updated>2008-07-14T07:39:45+00:00</updated>
    <title>Comment on Blog Setup by Song</title>
    <link rel="alternate" type="text/html" href="http://blog.nicksieger.com/articles/2008/07/10/blog-setup#comment-435"/>
    <content type="html">&lt;p&gt;Thanks for sharing&amp;#46; I am waiting for this&amp;#46; &lt;/p&gt;</content>
  </entry>
  <entry>
    <author>
      <name>Ivan Vint</name>
    </author>
    <id>urn:uuid:bbb7092c-fbc6-4113-8d6c-076f52df4fe8</id>
    <published>2008-07-10T09:27:40+00:00</published>
    <updated>2008-07-10T09:27:40+00:00</updated>
    <title>Comment on Blog Setup by Ivan Vint</title>
    <link rel="alternate" type="text/html" href="http://blog.nicksieger.com/articles/2008/07/10/blog-setup#comment-433"/>
    <content type="html">&lt;p&gt;Thanks, will try to setup a test blog on my gentoo linux desktop this weekend&amp;#46;&lt;/p&gt;</content>
  </entry>
  <entry>
    <author>
      <name>Alexander Mikhailian</name>
    </author>
    <id>urn:uuid:993cfd62-2c1e-4b8a-b79b-df24bccf1f09</id>
    <published>2008-07-10T08:37:14+00:00</published>
    <updated>2008-07-10T08:37:14+00:00</updated>
    <title>Comment on Blog Setup by Alexander Mikhailian</title>
    <link rel="alternate" type="text/html" href="http://blog.nicksieger.com/articles/2008/07/10/blog-setup#comment-432"/>
    <content type="html">&lt;p&gt;As you mention using activerecord&amp;#45;jdbcmysql&amp;#45;adapter, may I point you to a recent bug at &lt;a href='http://jira.codehaus.org/browse/JRUBY-2768' rel="nofollow"&gt;codehaus&lt;/a&gt; that I introduced asking not to force the &lt;tt&gt;utf8_bin&lt;/tt&gt; collation in the driver&amp;#46; &lt;/p&gt;

&lt;p&gt;As a next step and probably as a TODO for the 1&amp;#46;0 version of the ActiveRecord&amp;#45;JDBC, it would be nice to allow multiple encodings, and have &lt;tt&gt;utf&amp;#45;8&lt;/tt&gt; as a fallback enciding and not as the hard&amp;#45;wired rule&amp;#46;&lt;/p&gt;

&lt;p&gt;This is probably more in line with the attitude of MRI 1&amp;#46;8&amp;#46;6 towards the encodings&amp;#46; &lt;/p&gt;</content>
  </entry>
  <entry>
    <author>
      <name>Nick Sieger</name>
    </author>
    <id>urn:uuid:e7399075-a1ca-4af7-b122-ede5647c4fcc</id>
    <published>2008-07-10T05:10:27+00:00</published>
    <updated>2008-07-10T05:10:27+00:00</updated>
    <title>Blog Setup</title>
    <link rel="alternate" type="text/html" href="http://blog.nicksieger.com/articles/2008/07/10/blog-setup"/>
    <category term="jruby" scheme="http://blog.nicksieger.com/articles/tag/jruby"/>
    <category term="rails" scheme="http://blog.nicksieger.com/articles/tag/rails"/>
    <category term="warbler" scheme="http://blog.nicksieger.com/articles/tag/warbler"/>
    <category term="rack" scheme="http://blog.nicksieger.com/articles/tag/rack"/>
    <content type="html">&lt;p&gt;The other day &lt;a href="http://blog.nicksieger.com/articles/2008/07/06/this-blog-powered-by-glassfish-jruby-and-jruby-rack#comments"&gt;several people chimed in&lt;/a&gt; wondering how I set up this blog with JRuby and Glassfish&amp;#46; One of the reasons I didn&amp;#8217;t include the details in the post is that it&amp;#8217;s not really much different than any JRuby/Glassfish/Warbler deployment, but in case you don&amp;#8217;t know what that looks like, here are the basics&amp;#46;&lt;/p&gt;

&lt;h3&gt;Preconditions (Java)&lt;/h3&gt;

&lt;p&gt;I&amp;#8217;m running on a &lt;a href="http://joyent.com/accelerator"&gt;Joyent Accelerator&lt;/a&gt;, which runs &lt;a href="http://opensolaris.org/"&gt;OpenSolaris&lt;/a&gt;, which has JDK 6 installed by default&amp;#46; If you&amp;#8217;re running on some flavor of Linux, hopefully &lt;a href="https://jdk-distros.dev.java.net/"&gt;there&amp;#8217;s a package available for you to install&lt;/a&gt;, otherwise you may have to &lt;a href="http://www.java.com/en/download/help/5000010500.xml"&gt;download a self&amp;#45;extracting binary&lt;/a&gt;&amp;#46;&lt;/p&gt;

&lt;h3&gt;&lt;a href="https://glassfish.dev.java.net/downloads/v2ur2-b04.html"&gt;Install Glassfish&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;This step is actually straightforward; not at all as problematic as you might expect of a piece of Java technology! In the parent directory where you want Glassfish to be installed (substituting the name of the Glassfish jar you downloaded as appropriate):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;java -Xmx256m -jar glassfish-installer-v2ur2-b04-sunos_x86.jar
cd glassfish
chmod -R +x lib/ant/bin
./lib/ant/bin/ant -f setup.xml
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Start Glassfish&amp;#46;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;./bin/asadmin start-domain
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You may want to add &lt;code&gt;GLASSFISH/bin&lt;/code&gt; to your path so that you can run the Glassfish &lt;code&gt;asadmin&lt;/code&gt; command from anywhere&amp;#46;&lt;/p&gt;

&lt;p&gt;On Solaris, &lt;a href="http://www.sun.com/bigadmin/content/selfheal/smf-quickstart.jsp"&gt;SMF&lt;/a&gt; is the subsystem that is used to ensure services are started at boot time (among other things)&amp;#46; Glassfish &lt;a href="http://blogs.sun.com/bloggerkedar/entry/app_server_and_solaris_10"&gt;works nicely with SMF&lt;/a&gt;&amp;#46; On other systems, there may be &lt;code&gt;/etc/rc.d&lt;/code&gt; init scripts out there, or you can roll your own (&lt;code&gt;asadmin start-domain&lt;/code&gt; and &lt;code&gt;asadmin stop-domain&lt;/code&gt;)&amp;#46;&lt;/p&gt;

&lt;h3&gt;Install JRuby&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://dist.codehaus.org/jruby/jruby-bin-1.1.2.tar.gz"&gt;Download JRuby&lt;/a&gt; and &lt;a href="http://wiki.jruby.org/wiki/Getting_Started"&gt;unpack it somewhere&lt;/a&gt;&amp;#46; I recommend adding &lt;code&gt;JRUBY_HOME/bin&lt;/code&gt; to the end of your path, so it doesn&amp;#8217;t clash with Matz&amp;#45;Ruby&amp;#46;&lt;/p&gt;

&lt;h3&gt;Install Warbler and activerecord&amp;#45;jdbcmysql&amp;#45;adapter&lt;/h3&gt;

&lt;p&gt;In addition to Warbler, I&amp;#8217;m using the activerecord&amp;#45;jdbcmysql&amp;#45;adapter to connect to the blog&amp;#8217;s database&amp;#46; Both can be installed with Rubygems:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;jruby -S gem install warbler activerecord-jdbcmysql-adapter
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With Rails 2 and up, the application&amp;#8217;s &lt;code&gt;config/database.yml&lt;/code&gt; file should be updated for &lt;code&gt;adapter: jdbcmysql&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;% jdbc = defined?(JRUBY_VERSION) ? 'jdbc' : '' %&amp;gt;
development:
  adapter: &amp;lt;%= jdbc %&amp;gt;mysql
  encoding: utf8
  database: testapp_development
  username: root
  password:
  socket: /tmp/mysql.sock
# same for test/production...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Otherwise, you need to &lt;a href="http://wiki.jruby.org/wiki/Running_Rails_with_ActiveRecord-JDBC"&gt;jump through some extra environment&amp;#46;rb configuration hoops&lt;/a&gt;&amp;#46;&lt;/p&gt;

&lt;h3&gt;Configure Warbler&lt;/h3&gt;

&lt;p&gt;Warbler needs to be told about any gems that your application uses&amp;#46; To generate a Warbler configuration file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;jruby -S warble config
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The file is generated at &lt;code&gt;config/warble.rb&lt;/code&gt;&amp;#46; In it, modify the following sections:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;config.gems = ["activerecord-jdbcmysql-adapter"]
...
config.webxml.jruby.min.runtimes = 2
config.webxml.jruby.max.runtimes = 4
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Build and deploy the &amp;#46;war&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;jruby -S warble
asadmin deploy --contextroot / blog.war
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(&lt;code&gt;--contextroot /&lt;/code&gt; makes the application rooted at &lt;code&gt;/&lt;/code&gt; in the server, rather than at &lt;code&gt;/blog&lt;/code&gt; which would be the default&amp;#46;)&lt;/p&gt;

&lt;p&gt;At this point, the blog application is up and running on port 8080&amp;#46; I had previously been running the blog with an Apache/&amp;#46;htaccess&amp;#45;based setup reverse&amp;#45;proxying to mongrel, so all I had to do was change the port&amp;#46; I haven&amp;#8217;t touched it since&amp;#46;&lt;/p&gt;

&lt;h3&gt;But is this right for you?&lt;/h3&gt;

&lt;p&gt;Chances are, this setup is overkill for a simple blog&amp;#46; If you&amp;#8217;re going to try it, I&amp;#8217;d recommend at minimum running on a VPS with at least 1G of memory&amp;#46; But once you get the core pieces in place, updating and re&amp;#45;deploying the application is really just as simple as the last two commands&amp;#46; It&amp;#8217;s mundane and boring in its simplicity&amp;#46; But boring is good when you don&amp;#8217;t want to worry about having to keep Mongrel running, or max out the memory in your server and make it unstable&amp;#46;&lt;/p&gt;</content>
  </entry>
</feed>
