Nick Sieger: Blog Setup http://blog.nicksieger.com/articles/2008/07/10/blog-setup en-us 40 do what you love "Blog Setup" by Nick <p>ivar: we typically just include the <code>db</code> directory and rakefile in our war file and do these tasks on the server with a jruby installation&#46; I haven&#8217;t really seen any best practices in this area yet&#46; There&#8217;s been talk of having the application run its own migrations at application startup, but that seems a little dangerous&#46;&#46;&#46;</p> Wed, 23 Jul 2008 20:20:59 +0000 urn:uuid:962842f5-8d1a-4671-966b-fb59b6e7b983 http://blog.nicksieger.com/articles/2008/07/10/blog-setup#comment-450 "Blog Setup" by ivar <p>Having a simple recipe like this is very handy &#45; thanks ! My next question is if you have a suggested method for handling migrations ? (or rake tasks in general)</p> Wed, 23 Jul 2008 17:45:39 +0000 urn:uuid:e87181c8-34a6-434a-b72d-fff4b92cc7a2 http://blog.nicksieger.com/articles/2008/07/10/blog-setup#comment-449 "Blog Setup" by Song <p>Thanks for sharing&#46; I am waiting for this&#46; </p> Mon, 14 Jul 2008 07:39:44 +0000 urn:uuid:3b6c2da4-4cc6-4397-b5c7-5bd52e6dd85a http://blog.nicksieger.com/articles/2008/07/10/blog-setup#comment-435 "Blog Setup" by Ivan Vint <p>Thanks, will try to setup a test blog on my gentoo linux desktop this weekend&#46;</p> Thu, 10 Jul 2008 09:27:40 +0000 urn:uuid:bbb7092c-fbc6-4113-8d6c-076f52df4fe8 http://blog.nicksieger.com/articles/2008/07/10/blog-setup#comment-433 "Blog Setup" by Alexander Mikhailian <p>As you mention using activerecord&#45;jdbcmysql&#45;adapter, may I point you to a recent bug at <a href='http://jira.codehaus.org/browse/JRUBY-2768' rel="nofollow">codehaus</a> that I introduced asking not to force the <tt>utf8_bin</tt> collation in the driver&#46; </p> <p>As a next step and probably as a TODO for the 1&#46;0 version of the ActiveRecord&#45;JDBC, it would be nice to allow multiple encodings, and have <tt>utf&#45;8</tt> as a fallback enciding and not as the hard&#45;wired rule&#46;</p> <p>This is probably more in line with the attitude of MRI 1&#46;8&#46;6 towards the encodings&#46; </p> Thu, 10 Jul 2008 08:37:14 +0000 urn:uuid:993cfd62-2c1e-4b8a-b79b-df24bccf1f09 http://blog.nicksieger.com/articles/2008/07/10/blog-setup#comment-432 Blog Setup <p>The other day <a href="http://blog.nicksieger.com/articles/2008/07/06/this-blog-powered-by-glassfish-jruby-and-jruby-rack#comments">several people chimed in</a> wondering how I set up this blog with JRuby and Glassfish&#46; One of the reasons I didn&#8217;t include the details in the post is that it&#8217;s not really much different than any JRuby/Glassfish/Warbler deployment, but in case you don&#8217;t know what that looks like, here are the basics&#46;</p> <h3>Preconditions (Java)</h3> <p>I&#8217;m running on a <a href="http://joyent.com/accelerator">Joyent Accelerator</a>, which runs <a href="http://opensolaris.org/">OpenSolaris</a>, which has JDK 6 installed by default&#46; If you&#8217;re running on some flavor of Linux, hopefully <a href="https://jdk-distros.dev.java.net/">there&#8217;s a package available for you to install</a>, otherwise you may have to <a href="http://www.java.com/en/download/help/5000010500.xml">download a self&#45;extracting binary</a>&#46;</p> <h3><a href="https://glassfish.dev.java.net/downloads/v2ur2-b04.html">Install Glassfish</a></h3> <p>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):</p> <pre><code>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 </code></pre> <p>Start Glassfish&#46;</p> <pre><code>./bin/asadmin start-domain </code></pre> <p>You may want to add <code>GLASSFISH/bin</code> to your path so that you can run the Glassfish <code>asadmin</code> command from anywhere&#46;</p> <p>On Solaris, <a href="http://www.sun.com/bigadmin/content/selfheal/smf-quickstart.jsp">SMF</a> is the subsystem that is used to ensure services are started at boot time (among other things)&#46; Glassfish <a href="http://blogs.sun.com/bloggerkedar/entry/app_server_and_solaris_10">works nicely with SMF</a>&#46; On other systems, there may be <code>/etc/rc.d</code> init scripts out there, or you can roll your own (<code>asadmin start-domain</code> and <code>asadmin stop-domain</code>)&#46;</p> <h3>Install JRuby</h3> <p><a href="http://dist.codehaus.org/jruby/jruby-bin-1.1.2.tar.gz">Download JRuby</a> and <a href="http://wiki.jruby.org/wiki/Getting_Started">unpack it somewhere</a>&#46; I recommend adding <code>JRUBY_HOME/bin</code> to the end of your path, so it doesn&#8217;t clash with Matz&#45;Ruby&#46;</p> <h3>Install Warbler and activerecord&#45;jdbcmysql&#45;adapter</h3> <p>In addition to Warbler, I&#8217;m using the activerecord&#45;jdbcmysql&#45;adapter to connect to the blog&#8217;s database&#46; Both can be installed with Rubygems:</p> <pre><code>jruby -S gem install warbler activerecord-jdbcmysql-adapter </code></pre> <p>With Rails 2 and up, the application&#8217;s <code>config/database.yml</code> file should be updated for <code>adapter: jdbcmysql</code>:</p> <pre><code>&lt;% jdbc = defined?(JRUBY_VERSION) ? 'jdbc' : '' %&gt; development: adapter: &lt;%= jdbc %&gt;mysql encoding: utf8 database: testapp_development username: root password: socket: /tmp/mysql.sock # same for test/production... </code></pre> <p>Otherwise, you need to <a href="http://wiki.jruby.org/wiki/Running_Rails_with_ActiveRecord-JDBC">jump through some extra environment&#46;rb configuration hoops</a>&#46;</p> <h3>Configure Warbler</h3> <p>Warbler needs to be told about any gems that your application uses&#46; To generate a Warbler configuration file:</p> <pre><code>jruby -S warble config </code></pre> <p>The file is generated at <code>config/warble.rb</code>&#46; In it, modify the following sections:</p> <pre><code>config.gems = ["activerecord-jdbcmysql-adapter"] ... config.webxml.jruby.min.runtimes = 2 config.webxml.jruby.max.runtimes = 4 </code></pre> <h3>Build and deploy the &#46;war</h3> <pre><code>jruby -S warble asadmin deploy --contextroot / blog.war </code></pre> <p>(<code>--contextroot /</code> makes the application rooted at <code>/</code> in the server, rather than at <code>/blog</code> which would be the default&#46;)</p> <p>At this point, the blog application is up and running on port 8080&#46; I had previously been running the blog with an Apache/&#46;htaccess&#45;based setup reverse&#45;proxying to mongrel, so all I had to do was change the port&#46; I haven&#8217;t touched it since&#46;</p> <h3>But is this right for you?</h3> <p>Chances are, this setup is overkill for a simple blog&#46; If you&#8217;re going to try it, I&#8217;d recommend at minimum running on a VPS with at least 1G of memory&#46; But once you get the core pieces in place, updating and re&#45;deploying the application is really just as simple as the last two commands&#46; It&#8217;s mundane and boring in its simplicity&#46; But boring is good when you don&#8217;t want to worry about having to keep Mongrel running, or max out the memory in your server and make it unstable&#46;</p> Thu, 10 Jul 2008 05:10:27 +0000 urn:uuid:e7399075-a1ca-4af7-b122-ede5647c4fcc Nick Sieger http://blog.nicksieger.com/articles/2008/07/10/blog-setup jruby rails warbler rack http://blog.nicksieger.com/articles/trackback/431