public class CommandServer extends Object
Java command server. Especially targeted at executing imagemagick 'convert' in a system call.
It can work in two ways. The first way is as a stand-alone server. You start it up with a port-number argument then (or with a host-name and port-number argument, if you don't want it to listen on localhost). A server socket will be created and communication can happen via tcp.
~$ /usr/bin/java -jar mmbase-commandserver.jar michiel.omroep.nl 1679 Started ServerSocket[addr=michiel.omroep.nl/145.58.67.10,port=0,localport=1679]
If no arguments are provided, it will listen on stdin and return the result on stdout. This means that it can be installed as a inetd daemon (in UNIX systems). This boils down to placing something like
commandserver 1679/tcpIn /etc/services. And
commandserver stream tcp nowait nobody /usr/bin/java java -jar /home/michiel/mmbase/head/applications/commandserver/build/mmbase-commandserver.jarin /etc/inetd.conf. The result is the same (you can communicate with TCP), but avoids the hassle of having to keep the process alive.
The input for this server are 2 serialized String[] arrays (which will be the arguments for
Runtime.exec(String[], String[])), followed by the stdin for the command. It will return stdout of the process.
CommandExecutor to connect to the commandserver.| Modifier and Type | Class and Description |
|---|---|
static class |
CommandServer.Command |
static class |
CommandServer.Copier |
| Modifier and Type | Field and Description |
|---|---|
(package private) static ThreadFactory |
FACTORY |
(package private) static int |
number |
(package private) static BlockingQueue<Runnable> |
threadQueue |
(package private) static ThreadPoolExecutor |
threads |
| Constructor and Description |
|---|
CommandServer() |
| Modifier and Type | Method and Description |
|---|---|
static void |
main(String[] a) |
static String |
stackTrace(Throwable e,
int max) |
static int number
static final ThreadFactory FACTORY
static final BlockingQueue<Runnable> threadQueue
static final ThreadPoolExecutor threads
public static void main(String[] a) throws IOException, InterruptedException
IOExceptionInterruptedExceptionMMBase 1.9-SNAPSHOT - ${javadoctimestamp}