Thursday, November 28, 2013

Gradle - Release Script on Jenkins

You just put the following this to the Execute shell of the Post Steps on Jenkins.
APP_HOME=/usr/local/app
APP_NAME=appName
APP_JAR=appName.jar
APP_ZIP=appName.zip
for ip in ${IP_ADDRESS}
do
scp -o StrictHostKeyChecking=no ${WORKSPACE}/build/distributions/${APP_ZIP} user_id@${ip}:${APP_HOME}/
ssh -o StrictHostKeyChecking=no user_id@${ip} /usr/bin/unzip -o ${APP_HOME}/${APP_ZIP} -d ${APP_HOME}/${APP_NAME}/
ssh -o StrictHostKeyChecking=no user_id@${ip} /bin/mv -v ${APP_HOME}/${APP_NAME}/${APP_JAR} ${APP_HOME}/${APP_NAME}/bin/
done
view raw release.sh hosted with ❤ by GitHub

Also, you need to configure the following option on Jenkins.
Build > invoke Gradle script > Invoke Gradle Gradle Version >> Default
Build > invoke Gradle script > Tasks >> zip

Gradle - Sample build.gradle for Batch

This Gradle file is for batch.

apply plugin: 'java'
// Version number adhere to the name of zip file.
version = ''
// apply from: 'gradle/maven.gradle'
defaultTasks = ['assemble']
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
archivesBaseName = 'vertxWebSocketServer'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile group: 'commons-configuration', name: 'commons-configuration', version: '1.6'
compile group: 'commons-daemon', name: 'commons-daemon', version: '1.0.15'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.5'
runtime group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.5'
compile group: 'ch.qos.logback', name: 'logback-core', version: '1.0.13'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.13'
compile group: 'org.springframework', name: 'spring-core', version: '3.1.4.RELEASE'
compile group: 'org.springframework', name: 'spring-context', version: '3.1.4.RELEASE'
compile group: 'org.springframework', name: 'spring-context-support', version: '3.1.4.RELEASE'
compile group: 'org.springmodules', name: 'spring-modules-jakarta-commons', version: '0.9'
compile group: 'io.vertx', name: 'vertx-core', version: '2.0.2-final'
compile group: 'io.vertx', name: 'vertx-platform', version: '2.0.2-final'
}
task batch(type: Zip) {
from 'src/dist'
from jar.outputs.files
baseName = 'vertxWebSocketServer'
into('libs') {
from configurations.runtime
}
}
batch.dependsOn(assemble)
//assemble.dependsOn(batch)
view raw build.gradle hosted with ❤ by GitHub

Monday, November 25, 2013

Memcached - Set Conf files in Repcached

# memcached1 run config
-u cy_memcached
-p 11211
-l xxx.xxx.xxx.69
-d
-c 1024
-m 128
# Set replication
-x xxx.xxx.xxx.56
-X 11212
view raw memcached1.conf hosted with ❤ by GitHub
# memcached2 run config
-u cy_memcached
-p 11211
-l xxx.xxx.xxx.56
-d
-c 1024
-m 128
# Set replication
-x xxx.xxx.xxx..69
-X 11212
view raw memcached2.conf hosted with ❤ by GitHub

Tuesday, November 19, 2013

Vert.x - Vert.x and Highchart

@This is a sample for showing the chart on Real Time.
<html>
<head>
<title>Vert.x and Highchart</title>
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
<script src="js/sockjs-0.2.1.min.js"></script>
<script src="js/vertxbus.js"></script>
<script src="js/json2.js"></script>
</head>
<body>
<script language="javascript" type="text/javascript">
var xx = 0;
var yy = 0;
function myFunction(x, y) {
xx = x;
yy = y;
var div = document.getElementById('demo');
div.innerHTML = div.innerHTML + ', y=' + y;
}
var eb = new vertx.EventBus("http://localhost:8091/eventbus");
function browserHandler(msg, replyTo) {
var obj = JSON.parse(msg.text);
myFunction(obj.x, obj.y);
}
eb.onopen = function() {
eb.registerHandler('app.conduit', browserHandler);
};
// eb.publish('app.conduit', {text: 'Publish message: testaaaaaa'});
// This is from highchart.
$(function() {
Highcharts.setOptions({
global : {
useUTC : false
}
});
// Create the chart
$('#container').highcharts('StockChart', {
chart : {
events : {
load : function()
// set up the updating of the chart each second
var series = this.series[0];
setInterval(function() {
var x = (new Date()).getTime(), // current time
y = yy;
//y = Math.round(Math.random() * 100);
series.addPoint([x, y], true, true);
}, 1000);
}
}
},
rangeSelector: {
buttons: [{
count: 1,
type: 'minute',
text: '1M'
}, {
count: 5,
type: 'minute',
text: '5M'
}, {
type: 'all',
text: 'All'
}],
inputEnabled: false,
selected: 0
},
title : {
text : 'Live random data'
},
exporting: {
enabled: false
},
series : [{
name : 'Random data',
data : (function() {
// generate an array of random data
var data = [], time = (new Date()).getTime(), i;
for( i = -999; i <= 0; i++) {
data.push([
time + i * 1000,
Math.round(Math.random() * 100)
]);
}
return data;
})()
}]
});
});
</script>
<div id="container" style="height: 500px; min-width: 500px"></div>
<p id="demo">Pushed Data from Server >>> </p>
</body>
</html>
view raw gistfile1.html hosted with ❤ by GitHub

Reference

Saturday, November 9, 2013

MyDesign - This is a clock desging on the desk.

I designed the follow drawing when I worked the Industrial Design Company.


OS:Windows 97
Graphic Tool: Corel Draw

Why I was going to decide to enter the college for Industrial Design.
I had a reason. I will tell you why in this Session.


Friday, November 8, 2013

Java - Common Daemon in Java

@Download Commons Daemon
$ wget http://ftp.meisei-u.ac.jp/mirror/apache/dist//commons/daemon/source/commons-daemon-1.0.15-src.tar.gz
@Decompress
$ tar xvf ./commons-daemon-1.0.15-src.tar.gz
@Change Directory
$ cd /usr/local/src/commons-daemon-1.0.15-src/src/native/unix
@You need to build the "configure" program with:
$ ./support/buildconf.sh
@Set configuration and compile
$ ./configure --with-java=/usr/local/java
$ make
@Move jsvc to home of apps
$ mv /usr/local/src/commons-daemon-1.0.15-src/src/native/unix/jsvc /usr/local/app/

#!/bin/sh
# Batch process check script - start
# declare -i batchCnt
# batchCnt=`ps -ef | grep VertxWebSocketServerMain | grep -v "grep VertxWebSocketServerMain" | wc -l`
# if [ $batchCnt -ge 1 ]
# then
# echo "VertxWebSocketServerMain already started !!"
# exit 0
# fi
# Batch batch process check script - end
DAEMON_USER=njoonk
PID_FILE=/var/run/vertxWebSocket.pid
JAVA_HOME=/usr/local/java
BASEDIR=/usr/local/app/vertxWebSocketServer
PROGRAM_NAME=njoonk.vertx.main.VertxWebSocketServerMain
export JAVA_HOME
for f in `find $BASEDIR/lib -type f -name "*.jar"`
do
CLASSPATH=$CLASSPATH:$f
done
CLASSPATH=${CLASSPATH}:${BASEDIR}/bin/vertxWebSocketServer.jar
case "$1" in
"start")
$DAEMON_HOME/jsvc -user $DAEMON_USER -home $JAVA_HOME \
-wait 10 -pidfile $PID_FILE -outfile $DAEMON_HOME/logs/vertxWebSocket.out \
-server -Xmx128m -Xms128m -Xmn64m \
-errfile '&1' -cp $CLASSPATH $PROGRAM_NAME
#To get a verbose JVM
#-verbose \
#To get a debug of jsvc.
#-debug \
echo "Daemon start"
exit $?
;;
stop)
$DAEMON_HOME/jsvc -stop -pidfile $PID_FILE $PROGRAM_NAME
echo "Daemon stop"
exit $?
;;
*)
echo "Usage vertxWebSocket.sh start/stop"
exit 1;;
esac
exit 0
view raw daemonScript.sh hosted with ❤ by GitHub
public class VertxWebSocketServerMain implements Daemon {
@Override
public void destroy() {
// TODO Auto-generated method stub
System.out.println("destory");
}
@Override
public void init(DaemonContext arg0) throws DaemonInitException, Exception {
// TODO Auto-generated method stub
System.out.println("start >>> init");
new ClassPathXmlApplicationContext("springConfig.xml");
System.out.println("stop >>> init");
}
@Override
public void start() throws Exception {
// TODO Auto-generated method stub
System.out.println("start");
}
@Override
public void stop() throws Exception {
System.out.println("stop");
}
}

Link - Gradle

@Plug-in in Eclipse
http://www.kaczanowscy.pl/tomek/2010-03/gradle-ide-integration-eclipse-plugin

@Multi-modules
http://blog.tamashumi.com/2012/11/muliti-module-gradle-project-with-ide.html

Thursday, November 7, 2013

Troubleshooting - Vert.x

@The following error occurred in the Vert.x, it included the vertx-core-1.3.1.final.jar in the Lib.
The resolution is that you should use  vertx-core-2.0.2.final.jar.
------------------------------------------------------------------------------
nested exception is java.lang.IncompatibleClassChangeError: Found interface org.vertx.java.core.VertxFactory, but class was expected