<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Artisanal Software, LLC</title>
    <link>http://www.artisanalsoftwarellc.com</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>System Insights</title>
      <description>&lt;p&gt;Just started System Insights with Athulan Vijayaraghavan. This company is developing advanced software targeted at the manufacturing industry.&lt;/p&gt;

&lt;p&gt;For more information visit: &lt;a href="http://www.systeminsights.com"&gt;System Insights&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 16 May 2009 03:42:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:369cace6-62f3-490b-841b-bf69c106cfa7</guid>
      <author>Will Sobel</author>
      <link>http://www.artisanalsoftwarellc.com/articles/2009/05/16/system-insights</link>
    </item>
    <item>
      <title>Capistrano 2.0 and Mongrel</title>
      <description>&lt;p&gt;I&amp;#8217;ve been teaching a class over at UC Berkeley on Ruby on Rails and when we got to deployment, I didn&amp;#8217;t want to have all the students go through the headache of setting up their deploy repos, configuring mongrel and apache2 on the server for multiple applications. I have canned most of the configuration and setup procedure using cap and svn via http. It took me a little while to figure this all out and I thought it would may be of help to others out there. &lt;/p&gt;

&lt;p&gt;This article is assuming you have some control over you own machine as in a VPS scenario. If you&amp;#8217;re using shared hosting, cap is pretty much ready to go out of the box and you really don&amp;#8217;t have much choice about how things are set up.&lt;/p&gt;

&lt;p&gt;I have heard many people complain about the lack of documentation for Capistrano 2.0. It turns out the latest version is actually easier and more robust than the pervious version, but there is no good reference on how to do simple installations. I&amp;#8217;ve recently developed a plugin, since cap gems are no longer fashionable, that automates a deployment using capistrano, mongrel, and apache2. &lt;/p&gt;

&lt;p&gt;The deploy takes three steps and some pieces have been ported from the railsmachine gem or templating apache multi-app configuration. The plugin imports the code into the repository, checks out a version controlled working directory. Sets up the server directory structure, database, mongrel, and apache2 configuration. And then deploys the application to the server.&lt;/p&gt;

&lt;p&gt;In the following article I&amp;#8217;ll go over subversion setup, cap scripting for mongrel and apache2, and deployment.&lt;/p&gt;

&lt;h2&gt;Subversion Setup on Apache2&lt;/h2&gt;

&lt;p&gt;Subversion can be configured on apache2 fairly easily using web dav and the dav_svn module. There are a few gotcha&amp;#8217;s that will have you feeling rather irritated if you&amp;#8217;re not familiar with the arcane aspects of apache2 configuration. That being said, I found http to be the most robust way to install subversion for group access and provides the best cross platform behavior.&lt;/p&gt;

&lt;p&gt;First make sure you have subversion installed on your machine. Type the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
svn --version
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If this comes back with the subversion version, you&amp;#8217;re all set for the next step. Otherwise you will need to install subversion.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
apt-get install subversion
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To get subversion working with apache2, your need to install the dav_svn module for apache2. On most linuxs this can be done with:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
apt-get install libapache2-svn
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will also automatically activate the module. A quick regression on apache2; in the bad old days of apache 1.x you needed to activate all your modules by hacking at one large httpd.com file. Now, things are better, but if you don&amp;#8217;t know where to look, can be a bit confusing at first. In the &lt;code&gt;/etc/apache2/mods-available&lt;/code&gt; directory are all the modules that are currently installed. These modules are not available until you create a symbolic link to the &lt;code&gt;/etc/apache2/mods-enabled&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;For instance, to get the reverse proxy load balancing working in apache2 you need to do the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
ln -s /etc/apache2/mods-available/proxy* /etc/apache2/mods-enabled/
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I almost always use mod_deflate to automatically gzip, so while we&amp;#8217;re enabling modules, lets enable deflate as well.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
ln -s /etc/apache2/mods-available/deflate* /etc/apache2/mods-enabled
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This enabes all the proxy modules necessary for load balancing and deflate modules to reduce the size of your downloads. Simple, eh? Ok, now with those two steps we&amp;#8217;re on our way to getting subversion set up. You now need to set up the subversion repository on the site.&lt;/p&gt;

&lt;p&gt;Apache2 runs as user www-data and group www-data. The repositories will need to be run readable and writable by www-data. The default permissions on the files in the subversion will need to be changed if you create the repository as owned by anyone other than www-data. I just created it as www-data to avoid the hassle. &lt;/p&gt;

&lt;p&gt;So, for the apache2 configuration, you will want to add the following line at the bottom of the default apache2.conf file:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
NameVirtualHost *:80
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;NameVirtualHost allows multiple virtual directories to be associated with the same web server bound to the same port (80) but differentiated by the host name. So, you can have a www.foobar.com and a svn.foobar.com using completely different configurations. Place this line just before the following line:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
Include /etc/apache2/sites-enabled/
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, create the subversion site configuration file in the /etc/apache2/sites-available/ directory.&lt;/p&gt;

&lt;p&gt;/etc/apache2/sites-available/subversion:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;VirtualHost *:80&amp;gt;
  ServerName svn.foobar.com
  ServerAdmin admin@foobar.com
  &amp;lt;Location /repos&amp;gt;
    Order allow,deny
    Allow from all
    DAV svn
    SVNParentPath /subversion/repos

    AuthzSVNAccessFile /subversion/repos/repos-svn-authzfile
    Satisfy Any

    Require valid-user
    AuthType Basic
    AuthName "My subversion repository"
    AuthUserFile /subversion/repos/.dav_svn.passwd
  &amp;lt;/Location&amp;gt;

  ErrorLog /var/log/apache2/subversion-error.log
  LogLevel warn
  CustomLog /var/log/apache2/subversion-access.log combined
&amp;lt;/VirtualHost&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Now, I&amp;#8217;ll explain some of the more important parts of the configuration file. In the first few lines you have to tell apache the name of your server so it can choose the correct configuration for the host name. This is done by this line:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
  ServerName svn.foobar.com
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can add aditional &lt;code&gt;ServerAlias&lt;/code&gt;s to assoicate the configuration with secondary host names as well. The next piece is the definition of the location or the repository. Serving up the repo via http provides the most flexibility. You can use svn, a browser, and web_dav to access the code.&lt;/p&gt;

&lt;p&gt;If you are only serving up one repository, use the following declaration:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
      SVNPath /subversion/my_application
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The path will be the root directory of the repository.&lt;/p&gt;

&lt;p&gt;If you have multiple repositories, you need to use the &lt;code&gt;SVNParentPath&lt;/code&gt; declaration and specify the directory where all your repositories live.&lt;/p&gt;

&lt;p&gt;Now for the fun part, security. Unless you want everyone in the world to access your repository, you need to make sure you can enforce some basic login and access control. You need to enforce both Auth and subversion controls. Either one used separately will not work. If you use Auth you will require the user log in but all commits will be associated with (no author). &lt;/p&gt;

&lt;p&gt;On the other hand if you only use subversion authorization, it apache2 will not require a password. The Auth password file can be managed using the htpasswd utility. On LINUX or UNIX, htpasswd defaults to crypt. You should probably use MD5 passwords as they are more secure. To do this use the -m argument. The first time you create your AuthFile, use the -c argument as well.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
   htpasswd -c -m &amp;lt;account&amp;gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For every other account, do the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
   htpasswd -m &amp;lt;account&amp;gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You will be prompted to enter the password. The -b option will allow you to put the password on the command line if you&amp;#8217;re not worried about someone else seeing it.&lt;/p&gt;

&lt;p&gt;Now for the subversion access file:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
    AuthzSVNAccessFile /subversion/repos/repos-svn-authzfile
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This file is a text file you must maintain. Subversion allows very fine grained control over access to different directories and repositories. If you don&amp;#8217;t care, here&amp;#8217;s the simplest way to get it up and running. If you want more complex control, refer to the svn docs.&lt;/p&gt;

&lt;p&gt;In the file: /subversion/repos/repos-svn-authzfile&lt;/p&gt;

&lt;pre&gt;
[/]
user1 = rw
user2 = rw
&lt;/pre&gt;

&lt;p&gt;This will give users &lt;i&gt;user1&lt;/i&gt; &lt;i&gt;user2&lt;/i&gt; full read/write access to all repositories and all directories. &lt;/p&gt;

&lt;p&gt;To activate the subversion site, do the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
ln -s /etc/apache2/sites-available/subversion /etc/apache2/sites-enabled/
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And then restart apache2.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
apache2ctl restart
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s it for the configuration of apache2 and subversion using web-dav. &lt;/p&gt;

&lt;h2&gt;Capistrano 2.0 Deployment&lt;/h2&gt;

&lt;p&gt;I have created a plugin that will deploy your application in three steps. The first imports the app into subversion, the second configures the servers, and the last deploys the application. The scripts I developed are specifc to the class I&amp;#8217;m teaching, but can be generalized to almost any environement. &lt;/p&gt;

&lt;p&gt;Since there is scant documentation on cap 2.0, this will hopefully provide an example of what can be done. I got a lot of the ideas by reading the cap source; not the most pleasent way to understand a framework!&lt;/p&gt;

&lt;p&gt;If you want to create a template that can be used for multiple projects, this will be of interest. I have used this to quickly deploy student projects with minimal configuration.&lt;/p&gt;

&lt;p&gt;For a student to configure their application, they must supply the following information in their deploy.rb:&lt;/p&gt;

&lt;pre&gt;
set :user, 'a_deploy_user'
set :local_user, 'an_import_user'
set :application, 'app_name'
set :group_num, _number_

load 'vendor/plugins/rorclassify/rorclassify'
&lt;/pre&gt;

&lt;p&gt;The number is an integer that is used to compute the ports for each mongrel instance. This keeps all the applications on separate port numbers.&lt;/p&gt;</description>
      <pubDate>Fri, 19 Oct 2007 13:09:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:7eac9263-cbef-4dcc-80a2-56e63b82f014</guid>
      <author>Will Sobel</author>
      <link>http://www.artisanalsoftwarellc.com/articles/2007/10/19/capistrano-2-0-and-mongrel</link>
    </item>
    <item>
      <title>Ruby DB</title>
      <description>&lt;p&gt;For UCB Ruby Class&lt;/p&gt;

&lt;p&gt;&lt;a href="/files/ruby_db.zip"&gt;ruby_db.zip&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 08 Feb 2007 23:54:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:7633dc28-a230-43c1-9ca7-a1b622e4990f</guid>
      <author>Will Sobel</author>
      <link>http://www.artisanalsoftwarellc.com/articles/2007/02/08/ruby-db</link>
      <enclosure type="application/zip" length="3717" url="http://www.artisanalsoftwarellc.com/files/ruby_db.zip"/>
    </item>
    <item>
      <title>January AJAX Presentation</title>
      <description>&lt;p&gt;Here&amp;#8217;s the code from my AJAX presentation I gave. I&amp;#8217;ll write some more later..&lt;/p&gt;

&lt;p&gt;&lt;a href="/files/ajax.tar.gz"&gt;Ajax code&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 18 Jan 2007 21:23:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:bda83360-294a-4a46-9aaa-08f4e2667cc5</guid>
      <author>Will Sobel</author>
      <link>http://www.artisanalsoftwarellc.com/articles/2007/01/18/january-ajax-presentation</link>
      <category>meetup</category>
    </item>
  </channel>
</rss>

