<?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>Software development in the real world &#187; Deployment</title>
	<atom:link href="http://realitydrivendeveloper.com/category/deployment/feed/" rel="self" type="application/rss+xml" />
	<link>http://realitydrivendeveloper.com</link>
	<description></description>
	<lastBuildDate>Sat, 15 May 2010 02:44:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Session management after automated deployment best practices</title>
		<link>http://realitydrivendeveloper.com/2009/01/session-management-after-automated-deployment-best-practices/</link>
		<comments>http://realitydrivendeveloper.com/2009/01/session-management-after-automated-deployment-best-practices/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 19:12:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[sessions management]]></category>

		<guid isPermaLink="false">http://realitydrivendeveloper.com/?p=17</guid>
		<description><![CDATA[Now, I&#8217;m working on automated deployment platform for LAMP
environment, using Apache Ant.
Now it looks, something like that:
1. blocks all requests, and display &#8220;Website is under construction&#8221;
page.
2. implement database schema updates
3. update the application&#8217;s source code
4. unblock all the requests and hide &#8220;Website is under construction&#8221; page.
I thought, that we need the following:
after third, and before [...]]]></description>
			<content:encoded><![CDATA[<p>Now, I&#8217;m working on automated deployment platform for <a href="http://en.wikipedia.org/wiki/LAMP_(software_bundle)">LAMP</a><br />
environment, using <a href="http://en.wikipedia.org/wiki/Apache_Ant">Apache Ant</a>.</p>
<p>Now it looks, something like that:</p>
<p>1. blocks all requests, and display &#8220;<a href="http://realitydrivendeveloper.com/2008/12/index-page-under-construction-while-deploying/">Website is under construction</a>&#8221;<br />
page.<br />
2. implement database schema updates<br />
3. update the application&#8217;s source code<br />
4. unblock all the requests and hide &#8220;Website is under construction&#8221; page.</p>
<p>I thought, that we need the following:<br />
after third, and before fourth point I want the webserver to drop the sessions of already loggined users. I think, this practice is useful for automated deployment, because there might<br />
be significant changes in sessions handling and in the application<br />
core itself, so it is better to drop users&#8217; sessions and force them to<br />
login again.</p>
<p>Because it is an automated deployment and usually take very small time, so we can&#8217;t wait when loggined user&#8217;s session will expired.</p>
<p><span id="more-17"></span>The solution for the problem depends on where does the application stores sessions &#8211; files in system tmp folder, application tmp folder, database or some custom session-handling mechanism.</p>
<p>We store our session in the database, in single table called `sessions`. So when we need to drop the sessions, all we have to do is to execute SQL command: &#8220;TRUNCATE TABSE `sessions`;&#8221;. This can be done automatically, from command line. For example, like that:</p>
<div class="codesnip-container" >
<div class="codesnip">mysql &#8211;<span class="re2">user=</span>your_username &#8211;<span class="re2">password=</span>your_password your_database_name -e <span class="st0">&#8216;TRUNCATE TABLE sessions&#8217;</span></div>
</div>
<p>It is quite simple solution and most important <strong>working</strong> solution, in most cases it is enough, BUT <img src='http://realitydrivendeveloper.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /><br />
it is not ideal, and can be improved.</p>
<p>We decided to do it another way:<br />
new build can have just minor updates, which don&#8217;t refer with sessions in any way, so we should save user&#8217;s session in that case. Build manager, or person responsible for deployment should to know such details, whether sessions must be dropped after deployment or not(just hide unnecessary details), because it is developer&#8217;s responsibility to &#8220;tag&#8221; the build with &#8220;drop the sessions&#8221;, if it is necessary. This process, has to be automated too.</p>
<p>Then we started to think, how we can make that. The solution was simple and straightforward &#8211; give this responsibility to database SQL deltas automated updates mechanism.</p>
<p>We use DBDeploy for the task, which handle plain SQL format for SQL updates.<br />
So when developer sees the need of sessions drop after deployment, all he have to do is to add the &#8220;<em>TRUNCATE TABLE `sessions`;</em>&#8221; SQL command to new SQL delta script.</p>
<p>This solution, of course, becomes useless if sessions are stored in tmp folder, as default option in php.ini file. In that case, I wan&#8217;t to recommend you to drop the session files manually from that folder, but better stop apache web server before, for avoidance of conflicts.</p>
]]></content:encoded>
			<wfw:commentRss>http://realitydrivendeveloper.com/2009/01/session-management-after-automated-deployment-best-practices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Index page &#8220;Under construction&#8221; while deploying</title>
		<link>http://realitydrivendeveloper.com/2008/12/index-page-under-construction-while-deploying/</link>
		<comments>http://realitydrivendeveloper.com/2008/12/index-page-under-construction-while-deploying/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 11:01:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[apache ant]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[under contstuction]]></category>

		<guid isPermaLink="false">http://realitydrivendeveloper.com/?p=13</guid>
		<description><![CDATA[I have noticed a few times earlier on different sites an index pages with title &#8220;Please be patient, while we are deploying new software version. You&#8217;ll like it&#8221;. And one day, I decided that it is the time, to integrate the similar feature to our automated deployment process.
I think, that this page has to show [...]]]></description>
			<content:encoded><![CDATA[<p>I have noticed a few times earlier on different sites an index pages with title &#8220;Please be patient, while we are deploying new software version. You&#8217;ll like it&#8221;. And one day, I decided that it is the time, to integrate the similar feature to our automated deployment process.</p>
<p>I think, that this page has to show user some indication of action progress(real or fictional), not just a static page, user has to refresh to see if it is finished or not. What user has to do &#8211; is just open once the site, see the message, that it is &#8220;Under construction&#8221;, and stay the page for a while.</p>
<p>It has to refresh itself until the time, deployment has finished. After that it has to load index page of new version&#8217;s website.</p>
<p>I wan&#8217;t to tell you, how and when this new index page is setting up. Right, all the deployment processes can vary a lot depending on the software it deploys, environment it uses, deployment tools etc.</p>
<p><img class="aligncenter size-full wp-image-27" title="under_construction1" src="http://realitydrivendeveloper.com/wp-content/uploads/2008/12/under_construction1.jpg" alt="under_construction1" width="701" height="220" /><span id="more-13"></span></p>
<p>What is highly recommended in most cases:</p>
<p><strong>1.</strong> Install new index page with &#8220;Under construction&#8221; message</p>
<p><strong>2.</strong> block all the web site&#8217;s pages, except index</p>
<p>== different actions here(DB updates, server restart, caching refresh etc.) ==</p>
<p><strong>3.</strong> unblock all the pages(except index)</p>
<p><strong>4.</strong> delete &#8220;Under construction&#8221; page</p>
<p>That is how, I did it:</p>
<p>It is an Apache Ant build file, with the following contents:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc3"><span class="re1">&lt;</span>?xml <span class="re0">version</span>=<span class="st0">&#8220;1.0&#8243;</span> <span class="re0">encoding</span>=<span class="st0">&#8220;UTF-8&#8243;</span>?<span class="re2">&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;project</span> <span class="re0">name</span>=<span class="st0">&#8220;Under construction page&#8221;</span> <span class="re0">basedir</span>=<span class="st0">&#8220;.&#8221;</span><span class="re2">&gt;</span></span></p>
<p><span class="sc3"><span class="re1">&lt;target</span> <span class="re0">name</span>=<span class="st0">&#8220;show-splash-screen-while-deployment&#8221;</span><span class="re2">&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;exec</span> <span class="re0">executable</span>=<span class="st0">&#8220;cp&#8221;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;arg</span> <span class="re0">value</span>=<span class="st0">&#8220;.htaccess&#8221;</span><span class="re2">/&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;arg</span> <span class="re0">value</span>=<span class="st0">&#8220;.htaccess-backup&#8221;</span><span class="re2">&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;/exec<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;exec</span> <span class="re0">executable</span>=<span class="st0">&#8220;cp&#8221;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;arg</span> <span class="re0">value</span>=<span class="st0">&#8220;.htaccess-block-all-except-index&#8221;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;arg</span> <span class="re0">value</span>=<span class="st0">&#8220;.htaccess&#8221;</span><span class="re2">/&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;/exec<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/target<span class="re2">&gt;</span></span></span></p>
<p><span class="sc3"><span class="re1">&lt;target</span> <span class="re0">name</span>=<span class="st0">&#8220;hide-splash-screen-while-deployment&#8221;</span><span class="re2">&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;exec</span> <span class="re0">executable</span>=<span class="st0">&#8220;mv&#8221;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;arg</span> <span class="re0">value</span>=<span class="st0">&#8220;.htaccess-backup&#8221;</span><span class="re2">&gt;</span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;arg</span> <span class="re0">value</span>=<span class="st0">&#8220;.htaccess&#8221;</span><span class="re2">&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;/exec<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/target<span class="re2">&gt;</span></span></span></p>
<p><span class="sc3"><span class="re1">&lt;/project<span class="re2">&gt;</span></span></span></div>
</div>
<p>To install our &#8220;Under construction&#8221; page &#8211; just run:</p>
<div class="codesnip-container" >
<div class="codesnip">ant show-splash-screen-while-deployment</div>
</div>
<p>It will backup your default .htaccess file, and replace it with new one, which catches all the queries and redirect it to the root of the web site.</p>
<p>And when deployment will be finished, run:</p>
<div class="codesnip-container" >
<div class="codesnip">ant hide-splash-screen-while-deployment</div>
</div>
<p>It will restore your default .htaccess file.</p>
<p>In attachment, you can find all those files you need to do the same.</p>
<p>That solution is not the best, and is not for types of projects.If you like the idea, mostly you&#8217;ll need to modify it to your demands and your environment.</p>
<p><a href="http://realitydrivendeveloper.com/wp-content/uploads/2008/12/under_construction_for_deployment.zip">Download an attachment</a></p>
<p>Have fun! <img src='http://realitydrivendeveloper.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://realitydrivendeveloper.com/2008/12/index-page-under-construction-while-deploying/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Versionable static content deployment</title>
		<link>http://realitydrivendeveloper.com/2008/12/versionable-static-content-deployment/</link>
		<comments>http://realitydrivendeveloper.com/2008/12/versionable-static-content-deployment/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 10:30:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[apache ant]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[packing]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://realitydrivendeveloper.com/?p=8</guid>
		<description><![CDATA[Recently, at some project, we planned to dedicate some time to improve our deployment and build packing process, so we can use the solution in future projects.
What we decided to do:

make a pack of all the Java scripts and CSSes, to reduce the page load time
make a static content versionable

If first is quite a common [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, at some project, we planned to dedicate some time to improve our deployment and build packing process, so we can use the solution in future projects.</p>
<p>What we decided to do:</p>
<ol>
<li>make a pack of all the Java scripts and CSSes, to reduce the page load time</li>
<li>make a static content versionable</li>
</ol>
<p>If first is quite a common practise, I wan&#8217;t to tell more about the second point, on example.<br />
We use an automatic deployment system. So installing of new software version can be done easily and takes little time. So, for example, if we faced some serious bug with CSS, something is very bad with User Interface and the problem is with some external CSS directive.</p>
<p>If we will just change solve the problem, locally in those CSS file, make a build and upload it to the server we&#8217;ll have some users, with loggined sessions and cached CSS files in browser. We have uploaded the fixed version of CSS, but user still see the old one, with bugs.</p>
<p>The same problems can arise with all the static content(java scripts, CSS files, images).  So we decided to make that content versionable too.  Main purpose is to force the browser to load new version of those content, when we deploy new version.</p>
<p>That is how we decided to do that:</p>
<p><span id="more-8"></span>if we change all the paths in HTML, to static content with some unique postfix, such as, for example &#8220;styles.css?ver1.2&#8243; or &#8220;logo.png?ver39&#8243; or even &#8220;logo.png?UUID-UUID-UUID-UUID-UUID&#8221;, we&#8217;ll force all the browsers to reload the files.  But, we have found that actual CI build number(not UUID or revision) works best for us, because it some bug arises we can know for sure, in what build is it, to make a bug fix and deploy new version.</p>
<p>I automated the process making the unique URL postfixes for static content while packing build, ready for deployment, by using the Apache Ant and sed. Here is the example:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc3"><span class="re1">&lt;target</span> <span class="re0">name</span>=<span class="st0">&#8220;tag-static-content&#8221;</span><span class="re2">&gt;</span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;exec</span> <span class="re0">command</span>=<span class="st0">&#8220;find ${build.dir} -type f -exec sed -i &#8217;s/BUILD_NUMBER/${build.number}/&#8217; {} <span class="es0">\;</span>&#8220;</span><span class="re2">&gt;</span></span><br />
<span class="sc3"><span class="re1">&lt;/target<span class="re2">&gt;</span></span></span></div>
</div>
<p>That command search for all the files recursively in the build.dir folder, and replaces all the matches &#8220;BUILD_NUMBER&#8221; to build.number value.</p>
<p>To make this command run your view templates have to look like that:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc3"><span class="re1">&lt;script</span> <span class="re0">type</span>=<span class="st0">&#8216;text/javascript&#8217;</span> <span class="re0">src</span>=<span class="st0">&#8216;http://realitydrivendeveloper.com/wp-includes/js/jquery/jquery.js?BUILD_NUMBER&#8217;</span><span class="re2">&gt;</span></span><span class="sc3"><span class="re1">&lt;/script<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;link</span> <span class="re0">rel</span>=<span class="st0">&#8217;stylesheet&#8217;</span> <span class="re0">href</span>=<span class="st0">&#8216;http://realitydrivendeveloper.com/wp-includes/js/thickbox/thickbox.css?ver=BUILD_NUMBER&#8217;</span> <span class="re0">type</span>=<span class="st0">&#8216;text/css&#8217;</span> <span class="re0">media</span>=<span class="st0">&#8216;all&#8217;</span> <span class="re2">/&gt;</span></span></div>
</div>
<p>So it will still works in development environment.</p>
<p>There are different ways of setting ${build.number} variable, depending on your repository vendor(if you want to tag it by revision number), continuous integration server(by using its build number), generate some unique string(<a href="http://en.wikipedia.org/wiki/Universally_Unique_Identifier">UUID</a>) and assign its value to the ${build.number} variable, or even to install ${build.number} value manually, but it is not desired.</p>
<p>For, example, here are some ideas:</p>
<p>http://www.zorched.net/2006/07/20/getting-the-revision-number-of-your-subversion-working-copy/</p>
<p>http://code.google.com/p/bamboo-ant-tasks/</p>
<p>You can reduce code duplication by using the wrappers for outputting the links for static content(images, javascripts and CSS).</p>
]]></content:encoded>
			<wfw:commentRss>http://realitydrivendeveloper.com/2008/12/versionable-static-content-deployment/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
