|
From: Everett T. <eve...@ne...> - 2004-03-30 23:39:07
|
hi leif,
this is exactly the behavior i'm looking for in an application i'm
wrapping. but when i read from System.in it doesn't seem to block. this
is the code:
// an observer process is started here
System.out.println("Events and errors will be logged to the log file.");
System.out.println("**** Press [Enter] to stop receiving messages. ****");
InputStream is = System.in;
try
{
// wait for user input to stop receiving messages
int x = is.read();
is.close();
}
catch (IOException e)
{
}
// shutdown the observer process
System.exit(0);
i get the following output from the wrapper:
// start up messages
INFO | 2004/03/30 16:35:22 | Events and errors will be logged to the log
file.
INFO | 2004/03/30 16:35:22 | **** Press [Enter] to stop receiving
messages. ****
INFO | 2004/03/30 16:35:22 | Wrapper Manager: ShutdownHook started
INFO | 2004/03/30 16:35:22 | Send a packet STOP : 0
DEBUG | 2004/03/30 16:35:22 | read a packet STOP : 0
DEBUG | 2004/03/30 16:35:22 | JVM requested a shutdown. (0)
DEBUG | 2004/03/30 16:35:22 | wrapperStopProcess(0) called.
DEBUG | 2004/03/30 16:35:22 | Sending stop signal to JVM
DEBUG | 2004/03/30 16:35:22 | send a packet STOP : NULL
INFO | 2004/03/30 16:35:22 | WrapperSimpleApp: start(args) end. Main
Completed=false, exitCode=null
INFO | 2004/03/30 16:35:22 | returned from listener.start()
INFO | 2004/03/30 16:35:22 | Send a packet STARTED :
INFO | 2004/03/30 16:35:22 | Received a packet STOP :
DEBUG | 2004/03/30 16:35:22 | read a packet STARTED :
DEBUG | 2004/03/30 16:35:22 | JVM signalled that it was started.
INFO | 2004/03/30 16:35:23 | Thread, Wrapper-Shutdown-Hook, handling the
shutdown process.
INFO | 2004/03/30 16:35:23 | calling listener.stop()
INFO | 2004/03/30 16:35:23 | WrapperSimpleApp: stop(0)
INFO | 2004/03/30 16:35:23 | returned from listener.stop()
INFO | 2004/03/30 16:35:23 | Send a packet STOPPED : 0
DEBUG | 2004/03/30 16:35:23 | read a packet STOPPED : 0
DEBUG | 2004/03/30 16:35:23 | JVM signalled that it was stopped.
INFO | 2004/03/30 16:35:23 | Closing socket.
INFO | 2004/03/30 16:35:23 | Closed socket: java.net.SocketException:
Socket operation on nonsocket: recv failed
DEBUG | 2004/03/30 16:35:23 | socket read no code (closed?).
INFO | 2004/03/30 16:35:24 | Server daemon shut down
INFO | 2004/03/30 16:35:24 | Wrapper Manager: ShutdownHook complete
DEBUG | 2004/03/30 16:35:24 | JVM exited normally.
STATUS | 2004/03/30 16:35:24 | <-- Wrapper Stopped
any idea why the call to read() isn't blocking?
thanks,
everett
At 10:40 AM Saturday 3/27/2004, you wrote:
>Barney,
> You are actually the second person this month to run into problems
> with the way I
>had implemented this.
>
> For a number of reasons, it is not possible for the System.in
> InputStream to be used
>when running under the Java Service Wrapper. Doing so was resulting in a very
>cryptic exception from deep within Java. To clear things up for users, I
>had replaced
>that exception with one of my own which provided a more useful explanation
>of the
>cause of the problem.
>
> The problem now is that when users try to integrate various
> applications with the
>Wrapper, some of those applications are making use of System.in. Even though
>the console input is not actually being used in some cases, the above
>exception is
>preventing those applications from being started.
>
> I have modified the Wrapper so that rather than throwing an exception,
> calls to
>read from System.in will now simply block forever. By doing this
>applications that
>make use of System.in will simply behave as if there is no console input.
>
> Never the less. I do have the Wrapper print the following message to
> the console
>whenever a thread attempts to read from System.in. I was worried that not
>doing
>something would cause users endless hours of frustration as they tried to
>figure out
>why they were unable to read any input.
>
>WARNING - System.in can not be used when the JVM is being controlled by
>the Java
>Service Wrapper. Calls will block indefinitely.
>
> Let me know if you have any comments on this. If no reasons why this
> would be
>a problem pop up then this will be in the 3.1.0 release.
>
>Cheers,
>Leif
|