Showing posts with label ops. Show all posts
Showing posts with label ops. Show all posts

Thursday, February 9, 2012

Putting Apache in front of Tomcat

Download and install Apache as a service.
Download mod_jk.so and drop in Apache/modules/ directory.
Modify Apache/conf/httpd.conf

   LoadModule jk_module modules/mod_jk.so
   Include conf/extra/httpd-vhosts.conf

Modify Apache/conf/extra/httpd-vhosts.conf

   JkWorkersFile "/Tomcat/conf/workers.properties"
   <virtualhost *:80="">
      JkMount /* ajp13-8080
   </virtualhost>

Start Apache.
Download and install Tomcat as a service.
Create Tomcat/conf/workers.properties

   workers.tomcat_home="/tomcat"    
   workers.java_home="/Program Files/Java/jdk1.7.0_02"
   ps=/    
   worker.list=ajp13-8080 
   worker.ajp13-8080.port=8009 
   worker.ajp13-8080.host=localhost 
   worker.ajp13-8080.type=ajp13 
   worker.ajp13-8080.lbfactor=1

Start Tomcat.

That's it!
Read More »

Friday, September 30, 2011

Migrating from Git to Svn and Svn to Git

The following steps will migrate to and from GIT while maintaining all commit history.

svn2git# First, create a new GIT Repo
# Then, do the following
git svn init <svnUrl>/<svnRepoName>
cd <svnRepoName>
git svn fetch
git svn rebase
git remote add new <user>@<gitRepo>
git push new master

git2svn# First, create a new SVN Repo (with at least 1 file in it)
# Then, do the following
git svn clone <svnUrl>/<svnRepoName>
cd <svnRepoName>
git remote add old <gitRepo>
git fetch old
git checkout -b old_master old/master
git rebase --onto master --root
git svn dcommit
Read More »

Monday, June 13, 2011

Groovy JMX MBean Viewer instead of JConsole

You might be monitoring something with JConsole, and thinking, how can I automate this check?

Answer: With Groovy!

Here is an example of how easy it is to probe an ActiveMQ MBean that sits on 2 App Servers.

import javax.management.remote.*

['11.12.13.123', '11.12.13.124'].each { serverIp ->
   def server = jmxConnect(serverIp)
   def mbean = new GroovyMBean(server, 'org.apache.activemq:BrokerName=appEventBroker,Type=Queue,Destination=appEventQueue')
   println "On app server $serverIp"
   printQueueStatus(mbean)
}

def jmxConnect(serverIp) {
   def url = "service:jmx:rmi:///jndi/rmi://$serverIp:8999/jmxrmi"
   def env = [(JMXConnector.CREDENTIALS): (String[])['myRole', 'myPassword']]
   def connection = JMXConnectorFactory.connect(new JMXServiceURL(url), env)
   def server = connection.MBeanServerConnection
   return server
}

def printQueueStatus(mbean) {
   println "DequeueCount: $mbean.DequeueCount"
   println "EnqueueCount: $mbean.EnqueueCount"
}

Read More »

Wednesday, September 30, 2009

10 Things You Could Automate with Hudson CI

Here is a presentation I recently gave on the topic.

Read More »

Wednesday, June 10, 2009

Gant Helper

Using Gant for build scripts is pretty cool because it is a lightweight facade over Ant. You can do anything you can do in Ant by converting the syntax, but also mix in Groovy code. Using Groovy to script means better reuse of code and shorter build scripts. To learn more about Gant, read this page: http://gant.codehaus.org/

For those of you familiar with Gant, I have created a few helper closures at the top of my script that you may find useful.

includeTool << env = { 
variable -> return System.getenv()[variable] }
prop = { propKey -> return ant.project.properties[propKey] }
log = { target -> println "\n[${target.name}] ${target.description}" }
run = { command -> def out = ""; execute.shell(command, outProcessing:{out+=it+"\n"}); return out}

"env" - shortcut to reading environment variables. Example:

buildNumber = env('BUILD_NUMBER')

"prop" - shortcut to reading properties that were loaded into ant. Example:

appName = prop.'application.name' //If you know Groovy, you know it could also be: prop('application.name')

"log" - By default, Gant won't print the targets as they are executed. You get the Ant task prints, but this is helpful when you use "depends" and want to follow the script. Just use "log(it)" or "log it" at the top of each target in you script. Example:

target(compile: 'Compile everything') {
log(it)
ant.groovyc( ... )
}

Prints:

[compile] Compile everything
[groovyc] Compiling 1 source file
It can also be used for methods by manually passing the "it" object:
def junit() {
log([name:'junit', description:'Runs all JUnit Tests'])
}

"run" - executes a shell command and also returns the output. Example:

def svnlogOut = run("svn info")
println svnlogOut
Read More »