<?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>Captain Codeman&#187; x64</title>
	<atom:link href="http://www.captaincodeman.com/tag/x64/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.captaincodeman.com</link>
	<description>Software Developer</description>
	<lastBuildDate>Fri, 15 Jul 2011 22:50:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Running ElasticSearch as a Service on Windows 2008 x64</title>
		<link>http://www.captaincodeman.com/2011/05/20/elasticsearch-windows-service-2008-x64/</link>
		<comments>http://www.captaincodeman.com/2011/05/20/elasticsearch-windows-service-2008-x64/#comments</comments>
		<pubDate>Fri, 20 May 2011 15:57:14 +0000</pubDate>
		<dc:creator>Captain Codeman</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[elasticsearch]]></category>
		<category><![CDATA[full-text]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[procrun]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[x64]]></category>

		<guid isPermaLink="false">http://www.captaincodeman.com/2011/05/20/elasticsearch-windows-service-2008-x64/</guid>
		<description><![CDATA[How to run ElasticSearch as a Windows Service on Windows 2008 x64


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I think I first started using <a href="http://lucene.apache.org/java/docs/index.html">Apache Lucene</a> for full-text indexing as part of NHibernate Search. At some point I decided I needed more control and did my own indexing using Lucene directly. Now, it seems the easiest approach is to make use of a packaged up search service and so I’ve been looking at <a href="http://www.elasticsearch.org/">ElasticSearch</a>. So far, I’m very happy with it – it’s doing everything it say’s on the box and lets me offload all the full-text indexing and search functionality.</p>
<p>The only issue I’ve come across is trying to run it as a service on 64-bit Windows 7 or Windows 2008. While there is a <a href="https://github.com/elasticsearch/elasticsearch-servicewrapper">service-wrapper</a> available it just wasn’t working for me and I think the x64 platform may be part of that as there was only a elasticsearch-windows-x86-<strong><span style="text-decoration: underline;">32</span></strong>.exe included, no elasticsearch-windows-x86-<strong><span style="text-decoration: underline;">64</span></strong>.exe. This service wrapper seems to be based off a product that doesn’t appear to have a free community edition for 64-bit Windows.</p>
<p>So, I had a hunt around for ‘how to run a Java app as a Windows Service’ and came across the <a href="http://commons.apache.org/daemon/procrun.html">Apache Commons Daemon</a> or ‘<a href="http://commons.apache.org/daemon/procrun.html">procrun</a>‘. This worked so I thought I’d share it here in case anyone else is trying to do the same thing.</p>
<p>First of all, there are the pre-requisites: it’s a Java app so you need to have the Sun Java SDK installed and JAVA_HOME environment variable set.</p>
<p><a href="http://www.elasticsearch.org/download">Download ElasticSearch</a> and extract it to a folder. I’m using 0.16.0 and put it into D:\elasticsearch (because Program Files and UAC caused too many issues for me).</p>
<p>Before trying to set it to run as a service it’s best to make sure it runs as a regular app first. To start ElasticSearch on Windows there is a “bin\elasticsearch.bat” file to launch it which should show it running. As an extra check, there is a handy little web-based admin tool you can get called <a href="https://github.com/mobz/elasticsearch-head">elasticsearch-head</a> which will show the running status and provides a neat little browser / search interface. I extract this to D:\elasticsearch\tools. When you open the index.html file it lets you connect to your elasticsearch instance and show it’s status:</p>
<p><a href="http://www.captaincodeman.com/wp-content/uploads/2011/05/created.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="created" src="http://www.captaincodeman.com/wp-content/uploads/2011/05/created_thumb.png" border="0" alt="created" width="640" height="409" /></a></p>
<p>Downloading the Apache Commons Daemon or procrun is a little harder because it isn’t in the links on the <a href="http://commons.apache.org/daemon/download_daemon.cgi">download page</a>. Instead you need to follow the ‘browse native binaries download area…’ link, then look in the windows folder for the zip file. The file I used was: <a title="http://apache.skazkaforyou.com//commons/daemon/binaries/1.0.5/windows/commons-daemon-1.0.5-bin-windows.zip" href="http://apache.skazkaforyou.com//commons/daemon/binaries/1.0.5/windows/commons-daemon-1.0.5-bin-windows.zip">commons-daemon-1.0.5-bin-windows.zip</a></p>
<p>Extract this to D:\elasticsearch\service and then copy the amd64\prunsrv.exe to the D:\elasticsearch\service folder to replace the x86 version (or skip this step if you are actually running on a 32-bit OS).</p>
<p>Although we can set everything up with the exe files as they are, we’re going to rename them because it makes it clearer what is running on Windows Task Manager if you have other processes using this service runner. The convention is to use the service name and append a ‘w’ to the GUI manager exe so they become:</p>
<p>prunsvr.exe =&gt; ElasticSearch.exe<br />
prunmgr.exe =&gt; ElasticSearchw.exe</p>
<p>Because we’ll be running things as a service it will be running under a different account than the regular process does when we run it interactively. I used the ‘NETWORK SERVICE’ account which is able to handle network traffic and gave this account full permissions to the D:\elasticsearch folder so it will also be able to create data and log files.</p>
<p>Figuring out the command line to actually run the service is what took the longest. With a bit of trial and error and looking at the output from the batch file to launch elasticsearch I ended up with this which ‘works on my machine’. If it doesn’t work on yours try enabling the echo output from the batch file and checking the parameters are the same.</p>
<p>It’s easiest to put this into a create.cmd file to make editing and running it easier:</p>
<pre>ElasticSearch.exe //IS//ElasticSearch --DisplayName="ElasticSearch" --Description="Distributed RESTful Full-Text Search Engine based on Lucene (http://www.elasticsearch.org/) --Install=D:\elasticsearch\service\ElasticSearch.exe --Classpath="D:\elasticsearch\lib\elasticsearch-0.16.0.jar;D:\elasticsearch\lib\*;D:\elasticsearch\lib\sigar\*" --Jvm="C:\Program Files\Java\jre6\bin\server\jvm.dll" --JvmMx=512 --JvmOptions="-Xms256m;-Xmx1g;-XX:+UseCompressedOops;-Xss128k;-XX:+UseParNewGC;-XX:+UseConcMarkSweepGC;-XX:+CMSParallelRemarkEnabled;-XX:SurvivorRatio=8;-XX:MaxTenuringThreshold=1;-XX:CMSInitiatingOccupancyFraction=75;-XX:+UseCMSInitiatingOccupancyOnly;-XX:+HeapDumpOnOutOfMemoryError;-Djline.enabled=false;-Delasticsearch;-Des-foreground=yes;-Des.path.home=D:\elasticsearch" --StartMode=jvm --StartClass=org.elasticsearch.bootstrap.Bootstrap --StartMethod=main --StartParams="" --StopMode=jvm --StopClass=org.elasticsearch.bootstrap.Bootstrap --StopMethod=main --StdOutput=auto --StdError=auto --LogLevel=Debug --LogPath="D:\elasticsearch\logs" --LogPrefix=service --ServiceUser="NT AUTHORITY\NetworkService" --Startup=auto</pre>
<p>Phew !</p>
<p>Running that should create the service and running the ElasticSearchw.exe should how pop-up a GUI that lets us view and edit all the settings. The various tabs are shown below and should correspond to the settings defined above:</p>
<p><a href="http://www.captaincodeman.com/wp-content/uploads/2011/05/1-general.png"><img style="background-image: none; margin: 10px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="1-general" src="http://www.captaincodeman.com/wp-content/uploads/2011/05/1-general_thumb.png" border="0" alt="1-general" width="240" height="230" /></a> <a href="http://www.captaincodeman.com/wp-content/uploads/2011/05/2-logon.png"><img style="background-image: none; margin: 10px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="2-logon" src="http://www.captaincodeman.com/wp-content/uploads/2011/05/2-logon_thumb.png" border="0" alt="2-logon" width="240" height="230" /></a></p>
<p><a href="http://www.captaincodeman.com/wp-content/uploads/2011/05/3-logging.png"><img style="background-image: none; margin: 10px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="3-logging" src="http://www.captaincodeman.com/wp-content/uploads/2011/05/3-logging_thumb.png" border="0" alt="3-logging" width="240" height="230" /></a>\<a href="http://www.captaincodeman.com/wp-content/uploads/2011/05/4-java.png"><img style="background-image: none; margin: 10px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="4-java" src="http://www.captaincodeman.com/wp-content/uploads/2011/05/4-java_thumb.png" border="0" alt="4-java" width="240" height="230" /></a></p>
<p><a href="http://www.captaincodeman.com/wp-content/uploads/2011/05/5-startup.png"><img style="background-image: none; margin: 10px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="5-startup" src="http://www.captaincodeman.com/wp-content/uploads/2011/05/5-startup_thumb.png" border="0" alt="5-startup" width="240" height="230" /></a> <a href="http://www.captaincodeman.com/wp-content/uploads/2011/05/6-shutdown.png"><img style="background-image: none; margin: 10px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="6-shutdown" src="http://www.captaincodeman.com/wp-content/uploads/2011/05/6-shutdown_thumb.png" border="0" alt="6-shutdown" width="240" height="230" /></a></p>
<p>You can also have the GUI run as a task-tray which gives you a handy way to start and stop the service while you’re developing. To do this, create a monitor.cmd file with the following command:</p>
<pre>start ElasticSearchw.exe //MS</pre>
<p>You should be able to right-click on the new tray icon and start the service:</p>
<p><a href="http://www.captaincodeman.com/wp-content/uploads/2011/05/starting.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="starting" src="http://www.captaincodeman.com/wp-content/uploads/2011/05/starting_thumb.png" border="0" alt="starting" width="499" height="188" /></a></p>
<p>This isn’t mandatory though – the service should appear in the normal Windows Service Manager where it can be stopped and started as usual:</p>
<p><a href="http://www.captaincodeman.com/wp-content/uploads/2011/05/windows-services.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="windows-services" src="http://www.captaincodeman.com/wp-content/uploads/2011/05/windows-services_thumb.png" border="0" alt="windows-services" width="640" height="445" /></a></p>
<p>Whether everything starts or not, you should get some useful information written to the log files. Here’s how mine looked after the service was started successfully.</p>
<p>service.2011-05-19.log:</p>
<pre style="font-size: 9px;">[2011-05-19 10:21:30] [debug] ( prunsrv.c:1494) Commons Daemon procrun log initialized
[2011-05-19 10:21:30] [info]  (          :0   ) Commons Daemon procrun (1.0.5.0 64-bit) started
[2011-05-19 10:21:30] [info]  (          :0   ) Running 'ElasticSearch' Service...
[2011-05-19 10:21:30] [debug] ( prunsrv.c:1246) Inside ServiceMain...
[2011-05-19 10:21:30] [info]  (          :0   ) Starting service...
[2011-05-19 10:21:30] [debug] ( javajni.c:206 ) loading jvm 'C:\Program Files\Java\jre6\bin\server\jvm.dll'
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[0] -Xms256m
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[1] -Xmx1g
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[2] -XX:+UseCompressedOops
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[3] -Xss128k
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[4] -XX:+UseParNewGC
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[5] -XX:+UseConcMarkSweepGC
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[6] -XX:+CMSParallelRemarkEnabled
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[7] -XX:SurvivorRatio=8
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[8] -XX:MaxTenuringThreshold=1
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[9] -XX:CMSInitiatingOccupancyFraction=75
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[10] -XX:+UseCMSInitiatingOccupancyOnly
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[11] -XX:+HeapDumpOnOutOfMemoryError
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[12] -Djline.enabled=false
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[13] -Delasticsearch
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[14] -Des-foreground=yes
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[15] -Des.path.home=D:\elasticsearch
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[16] -Djava.class.path=C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip;D:\elasticsearch\lib\elasticsearch-0.16.1.jar;D:\elasticsearch\lib\elasticsearch-0.16.1.jar;D:\elasticsearch\lib\jline-0.9.94.jar;D:\elasticsearch\lib\jna-3.2.7.jar;D:\elasticsearch\lib\log4j-1.2.15.jar;D:\elasticsearch\lib\lucene-analyzers-3.1.0.jar;D:\elasticsearch\lib\lucene-core-3.1.0.jar;D:\elasticsearch\lib\lucene-highlighter-3.1.0.jar;D:\elasticsearch\lib\lucene-memory-3.1.0.jar;D:\elasticsearch\lib\lucene-queries-3.1.0.jar;D:\elasticsearch\lib\sigar\sigar-1.6.4.jar
[2011-05-19 10:21:30] [debug] ( javajni.c:660 ) Jvm Option[17] -Xmx512m
[2011-05-19 10:21:31] [debug] ( javajni.c:891 ) Java Worker thread started org/elasticsearch/bootstrap/Bootstrap:main
[2011-05-19 10:21:32] [debug] ( prunsrv.c:1058) Java started org/elasticsearch/bootstrap/Bootstrap
[2011-05-19 10:21:32] [info]  (          :0   ) Service started in 2066 ms.
[2011-05-19 10:21:32] [debug] ( prunsrv.c:1369) Waiting for worker to finish...
[2011-05-19 10:21:39] [debug] ( javajni.c:907 ) Java Worker thread finished org/elasticsearch/bootstrap/Bootstrap:main with status=0
[2011-05-19 10:21:39] [debug] ( prunsrv.c:1374) Worker finished.
[2011-05-19 10:21:39] [debug] ( prunsrv.c:1397) Waiting for all threads to exit</pre>
<p>elasticsearch.log:</p>
<pre style="font-size: 9px;">[2011-05-19 10:21:32,709][INFO ][node                     ] [Hack] {elasticsearch/0.16.1}[2344]: initializing ...
[2011-05-19 10:21:32,711][INFO ][plugins                  ] [Hack] loaded []
[2011-05-19 10:21:36,149][INFO ][node                     ] [Hack] {elasticsearch/0.16.1}[2344]: initialized
[2011-05-19 10:21:36,150][INFO ][node                     ] [Hack] {elasticsearch/0.16.1}[2344]: starting ...
[2011-05-19 10:21:36,268][INFO ][transport                ] [Hack] bound_address {inet[/0.0.0.0:9300]}, publish_address {inet[/10.0.1.8:9300]}
[2011-05-19 10:21:39,311][INFO ][cluster.service          ] [Hack] new_master [Hack][Gkn9PLFTR0KdX2X__ybpIQ][inet[/10.0.1.8:9300]], reason: zen-disco-join (elected_as_master)
[2011-05-19 10:21:39,337][INFO ][discovery                ] [Hack] elasticsearch/Gkn9PLFTR0KdX2X__ybpIQ
[2011-05-19 10:21:39,351][INFO ][gateway                  ] [Hack] recovered [0] indices into cluster_state
[2011-05-19 10:21:39,366][INFO ][http                     ] [Hack] bound_address {inet[/0.0.0.0:9200]}, publish_address {inet[/10.0.1.8:9200]}
[2011-05-19 10:21:39,366][INFO ][node                     ] [Hack] {elasticsearch/0.16.1}[2344]: started</pre>
<p>Hopefully, this helps you get ElasticSearch up and running as a service on Windows x64. It’s a great app and really worth looking at. I’m hoping to make good use of it on a couple of projects, particularly the faceted search feature.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.captaincodeman.com/2011/05/20/elasticsearch-windows-service-2008-x64/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Running .NET Apps in 32-bit mode on 64-bit Windows</title>
		<link>http://www.captaincodeman.com/2007/12/17/running-net-apps-in-32-bit-mode-on-64-bit-windows/</link>
		<comments>http://www.captaincodeman.com/2007/12/17/running-net-apps-in-32-bit-mode-on-64-bit-windows/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 00:37:00 +0000</pubDate>
		<dc:creator>Captain Codeman</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[32 bit]]></category>
		<category><![CDATA[64 bit]]></category>
		<category><![CDATA[x64]]></category>
		<category><![CDATA[x86]]></category>

		<guid isPermaLink="false">http://blogs.intesoft.net/post.aspx?id=bc00b190-ee8d-4eb4-8777-61d68c4d24a2</guid>
		<description><![CDATA[The normal behavior for .NET 2.0 applications compiled with the default &#39;Any CPU&#39; platform is to run as 32-bit on x86 (32-bit) Windows and as 64-bit on x64 (64-bit) Windows. Occasionally, some apps won&#39;t run correctly &#8211; I&#39;ve recently run into this with&#160;CCNetConfig (a CruiseControl.NET Configuration tool) and have seen it before with other tools.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>
<span class="postbody">The normal behavior for .NET 2.0 applications compiled with the default &#39;Any CPU&#39; platform is to run as 32-bit on x86 (32-bit) Windows and as 64-bit on x64 (64-bit) Windows.</span>
</p>
<p>
<span class="postbody">Occasionally, some apps won&#39;t run correctly &#8211; I&#39;ve recently run into this with&nbsp;<a href="http://www.codeplex.com/ccnetconfig" target="_blank" title="CruiseControl.NET Configuration">CCNetConfig</a> (a CruiseControl.NET Configuration tool) and have seen it before with other tools. Another obscure scenario where it shows up is if you try to use the JET OleDB driver which will fail in 64-bit mode because there isn&#39;t one! (it has to be 32-bit).</span>
</p>
<p>
<span class="postbody">Rather than have to recompile the app or even worse, run a 32-bit Virtual Machine, there is an easy way to force .NET to run an app in 32-bit mode using the &#39;CorFlags.exe&#39; tool.</span>
</p>
<p>
<span class="postbody">Depending on your system this may be installed in different places. I&#39;ve seen it in different places on XP64 and Vista X64:</span>
</p>
<ul>
<li>
<div>
	<span class="postbody">C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\x64\CorFlags.exe </span>
	</div>
</li>
<li>
<div>
	<span class="postbody">C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\Bin\CorFlags.exe </span>
	</div>
</li>
</ul>
<p>
<span class="postbody">Running this from the command line with the path / filename of the app you want to change and the switch /32BIT+ to turn on 32-bit mode, e.g.:</span>
</p>
<pre>
<span class="postbody"><font face="courier new,courier">   CoreFlags.exe TheApp.exe /32BIT+</font></span>
</pre>
<p>
<span class="postbody"></span>
</p>
<p>
<span class="postbody">If that fixes the problem then you know that it <em><strong>is </strong></em>a 64-bit issue. You can re-enable 64-bit operation for the app by turning off the 32-bit switch with the parameter /32BIT-, e.g.:</span>
</p>
<pre>
<span class="postbody"><font face="courier new,courier">   CoreFlags.exe TheApp.exe /32BIT-</font></span>
</pre>
<p>
<span class="postbody"></span>
</p>
<p>
<span class="postbody">Voila &#8230; control over 32-bit and 64-bit execution without doing a recompile! I&#39;m not 100% certain but I think that this switch sets the same flag that the &#39;x86&#39; and &#39;Any CPU&#39; targets set in Visual Studio.</span></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.captaincodeman.com/2007/12/17/running-net-apps-in-32-bit-mode-on-64-bit-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

