$ 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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
} |
No comments:
Post a Comment