renamed fda script to server and added script to startup the viewer

This commit is contained in:
2014-04-07 15:11:01 +02:00
parent 1077ec8ab3
commit 8522d46813
4 changed files with 79 additions and 4 deletions

View File

@@ -0,0 +1,40 @@
#!/bin/bash
CURRENTDIR=`pwd`
# Resolve symlinks
BASEDIR=$0
while [ -h "$BASEDIR" ]; do
ls=`ls -ld "$BASEDIR"`
link=`expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null`
if expr "$link" : '^/' 2> /dev/null >/dev/null; then
BASEDIR="$link"
else
BASEDIR="`dirname "$BASEDIR"`/$link"
fi
done
BASEDIR=`dirname "$BASEDIR"`
SCRIPTNAME=`basename ${0}`
APPLICATION_HOME=$BASEDIR/../..
LIB_DIR=`find $BASEDIR/../lib -name "*.jar"`
LIB_DIR=`echo $LIB_DIR | sed -e 's/ /:/g'`
CLASSPATH=${APPLICATION_HOME}/config/:$LIB_DIR
ARGUMENTS=
VM_ARGUMENTS=
for i in $@
do
if [ `expr $i : '-D.*'` != '0' ] ;then
# Extract VM options
VM_ARGUMENTS="$VM_ARGUMENTS $i"
else
ARGUMENTS="$ARGUMENTS $i"
fi
done
# Execute java
java -Xmx1024m -XX:MaxPermSize=128m -cp $CLASSPATH -Dch.psi.fda.home=${APPLICATION_HOME} -Djava.util.logging.config.file=${APPLICATION_HOME}/config/logging.properties $VM_ARGUMENTS ch.psi.fda.ViewerMain $ARGUMENTS

View File

@@ -33,6 +33,12 @@ import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.ScrollPaneLayout;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
@@ -137,9 +143,38 @@ public class ViewerMain {
*/
public static void main(String[] args) {
int port = 10000;
String hostname = "localhost";
Options options = new Options();
options.addOption("h", false, "Help");
options.addOption("p", true, "Server port (default: "+port+")");
options.addOption("s", true, "Server address (default: "+hostname+")");
GnuParser parser = new GnuParser();
try {
CommandLine line = parser.parse(options, args);
if (line.hasOption("p")) {
port = Integer.parseInt(line.getOptionValue("p"));
}
if (line.hasOption("s")) {
hostname = line.getOptionValue("s");
}
if (line.hasOption("h")) {
HelpFormatter f = new HelpFormatter();
f.printHelp("viewer", options);
return;
}
} catch (ParseException e1) {
System.err.println("Wrong arguments: "+ e1.getMessage());
System.exit(-1);
}
try{
ViewerMain e = new ViewerMain("tcp://emac:10000");
ViewerMain e = new ViewerMain("tcp://"+hostname+":"+port);
e.visualize();
}
catch(Exception ee){

View File

@@ -1,7 +1,6 @@
package ch.psi.fda.rest;
import java.io.IOException;
import java.net.InetAddress;
import java.net.URI;
import java.util.concurrent.CountDownLatch;
import java.util.logging.Logger;
@@ -30,7 +29,8 @@ public class FdaServer {
public static void main(String[] args) throws IOException, ParseException {
int port = 8080;
String hostname = InetAddress.getLocalHost().getHostName();
// String hostname = InetAddress.getLocalHost().getHostName();
String hostname = "localhost";
Options options = new Options();
options.addOption("h", false, "Help");
@@ -48,7 +48,7 @@ public class FdaServer {
}
if (line.hasOption("h")) {
HelpFormatter f = new HelpFormatter();
f.printHelp("broker", options);
f.printHelp("fda", options);
return;
}