|
From: Brent P. <bop...@ma...> - 2005-07-14 17:07:29
|
I'm starting my service from another separate java application. Occasionally
there is a situation when the service can't start properly due to the existence
of a lock file. I want the java application to be able to realize when this
happens and react accordingly. Ideally, I would like the service to exit with a
specific integer that indicates this situation. (Alternatively, I could pass
some string to standard out (or error) that the java application can look for.)
I have been using the ProcessBuilder to start the service. Here is a snippet
of that code:
ProcessBuilder pb = new ProcessBuilder(args[0], args[1], args[2]);
Process pr = pb.start();
//code here to capture standard err and out
int exitVal =pr.waitFor();
System.out.println("exit value: " + exitVal);
Judging from the wrapper log it seems like JSW is passing my exit value
properly. But the value is not being printed outfrom the above code. (the value
passed is 9, but it returns 1 or 2).
I also can't figure out an easy way to print to standard out since JSW traps all that
and prints it to the wrapper log.
Does anybody have any other ideas about a better way to go about this? I realize that
this may not be a problem with JSW, but a problem with how I'm trying to retrieve
the exit value. Maybe there a better approach altogether.. I'll post
some other info below. Please let me know if I should add anything else.
Thanks!
Brent
Other info:
-------------------
I'm using integration method 3. During startup of my application, there
occasionally is a problem with a lock file being in place. My app detects when
that occurs and passes an exception back to the Main class(which implements
wrapperlistener). When this happens, the start() method in this class returns an
integer other than 0 (in this case, 9) to indicate a failed startup.
Sample output:
-------------------
C:\sandbox\update\bin>java Test wrapper.exe -t "../conf/wrapper.conf"
out: wrapper | Starting the eGranary Client Update Service service...
out: wrapper | The eGranary Client Update Service service was launched, but fai
led to start.
exit value: 1
C:\sandbox\update\bin>java Test net start egranupd
out: The eGranary Client Update Service service is starting....
err: The eGranary Client Update Service service could not be started.
err: A system error has occurred.
err: System error 1067 has occurred.
err: The process terminated unexpectedly.
exit value: 2
wrapper.log:
--------------------
DEBUG | wrapper | 2005/07/14 11:45:53 | Working directory set to: ../
STATUS | wrapper | 2005/07/14 11:45:53 | Starting the eGranary Client Update Service service...
DEBUG | wrapper | 2005/07/14 11:45:53 | Working directory set to: ../
STATUS | wrapper | 2005/07/14 11:45:53 | --> Wrapper Started as Service
DEBUG | wrapper | 2005/07/14 11:45:53 | Using system timer.
DEBUG | wrapperp | 2005/07/14 11:45:54 | server listening on port 32000.
STATUS | wrapper | 2005/07/14 11:45:54 | Launching a JVM...
DEBUG | wrapper | 2005/07/14 11:45:54 | command: "C:\WINDOWS\system32\java.exe" -Dconfig.filename=conf\EGranUpd.conf.xml -Dconfig.location=file -Djava.library.path="lib" -classpath "dist/eGranUpd.jar;lib/wrapper.jar;lib/jfig.jar;lib/log4j.jar;lib/lucene.jar;lib/FileTracking.jar;lib/je.jar" -Dwrapper.key="UmfiEFkaKo5d9MJN" -Dwrapper.port=32000 -Dwrapper.debug="TRUE" -Dwrapper.use_system_time="TRUE" -Dwrapper.version="3.1.2" -Dwrapper.native_library="wrapper" -Dwrapper.service="TRUE" -Dwrapper.cpu.timeout="10" -Dwrapper.jvmid=1 org.widernet.upd_svc.Main
DEBUG | wrapper | 2005/07/14 11:45:54 | JVM started (PID=1276)
INFO | jvm 1 | 2005/07/14 11:45:54 | WrapperManager class initialized by thread: main Using classloader: sun.misc.Launcher$AppClassLoader@133056f
INFO | jvm 1 | 2005/07/14 11:45:54 | Wrapper Manager: JVM #1
INFO | jvm 1 | 2005/07/14 11:45:54 | Wrapper Manager: Registering shutdown hook
INFO | jvm 1 | 2005/07/14 11:45:54 | Wrapper Manager: Using wrapper
INFO | jvm 1 | 2005/07/14 11:45:54 | Loaded native library: wrapper.dll
INFO | jvm 1 | 2005/07/14 11:45:54 | Calling native initialization method.
INFO | jvm 1 | 2005/07/14 11:45:54 | Initializing WrapperManager native library.
INFO | jvm 1 | 2005/07/14 11:45:54 | Java Executable: C:\WINDOWS\system32\java.exe
INFO | jvm 1 | 2005/07/14 11:45:54 | Windows version: 5.1.2600
INFO | jvm 1 | 2005/07/14 11:45:54 | Java Version : 1.5.0_03-b07 Java HotSpot(TM) Client VM
INFO | jvm 1 | 2005/07/14 11:45:54 | Java VM Vendor : Sun Microsystems Inc.
INFO | jvm 1 | 2005/07/14 11:45:54 |
INFO | jvm 1 | 2005/07/14 11:45:54 | Wrapper (Version 3.1.2) http://wrapper.tanukisoftware.org
INFO | jvm 1 | 2005/07/14 11:45:54 |
INFO | jvm 1 | 2005/07/14 11:45:54 | WrapperManager.start(org.widernet.upd_svc.Main@a90653, args[]) called by thread: main
INFO | jvm 1 | 2005/07/14 11:45:54 | Open socket to wrapper...
INFO | jvm 1 | 2005/07/14 11:45:54 | Opened Socket
INFO | jvm 1 | 2005/07/14 11:45:54 | Send a packet KEY : UmfiEFkaKo5d9MJN
INFO | jvm 1 | 2005/07/14 11:45:54 | handleSocket(Socket[addr=localhost/127.0.0.1,port=32000,localport=1516])
DEBUG | wrapperp | 2005/07/14 11:45:54 | accepted a socket from 127.0.0.1 on port 1516
DEBUG | wrapperp | 2005/07/14 11:45:54 | read a packet KEY : UmfiEFkaKo5d9MJN
DEBUG | wrapper | 2005/07/14 11:45:54 | Got key from JVM: UmfiEFkaKo5d9MJN
DEBUG | wrapperp | 2005/07/14 11:45:54 | send a packet LOW_LOG_LEVEL : 1
DEBUG | wrapperp | 2005/07/14 11:45:54 | send a packet PING_TIMEOUT : 30
DEBUG | wrapper | 2005/07/14 11:45:54 | Start Application.
DEBUG | wrapperp | 2005/07/14 11:45:54 | send a packet START : start
INFO | jvm 1 | 2005/07/14 11:45:54 | Received a packet LOW_LOG_LEVEL : 1
INFO | jvm 1 | 2005/07/14 11:45:54 | Wrapper Manager: LowLogLevel from Wrapper is 1
INFO | jvm 1 | 2005/07/14 11:45:54 | Received a packet PING_TIMEOUT : 30
INFO | jvm 1 | 2005/07/14 11:45:54 | Wrapper Manager: PingTimeout from Wrapper is 30000
INFO | jvm 1 | 2005/07/14 11:45:54 | Received a packet START : start
INFO | jvm 1 | 2005/07/14 11:45:54 | calling listener.start()
INFO | jvm 1 | 2005/07/14 11:45:54 | 0 [Wrapper-Connection] INFO root - workingdir: C:\sandbox\update
INFO | jvm 1 | 2005/07/14 11:45:54 | 0 [Wrapper-Connection] INFO root - initializing internal configuration
INFO | jvm 1 | 2005/07/14 11:45:54 | 31 [Wrapper-Connection] INFO org.igfay.jfig.XMLJFigParser - Process file conf\EGranUpd.conf.xml
DEBUG | wrapper | 2005/07/14 11:45:54 | Pause reading child output to share cycles.
INFO | jvm 1 | 2005/07/14 11:45:54 | 140 [Wrapper-Connection] INFO root - loading Log4j config file: C:\sandbox\update/conf/log4j.xml
INFO | jvm 1 | 2005/07/14 11:45:54 | INFO - --------------------------------------
INFO | jvm 1 | 2005/07/14 11:45:54 | INFO -
INFO | jvm 1 | 2005/07/14 11:45:54 | INFO - Section: a_paths
INFO | jvm 1 | 2005/07/14 11:45:54 | INFO -
INFO | jvm 1 | 2005/07/14 11:45:54 | INFO - Section: indexer
INFO | jvm 1 | 2005/07/14 11:45:54 | INFO -
INFO | jvm 1 | 2005/07/14 11:45:54 | INFO - Section: lucene
INFO | jvm 1 | 2005/07/14 11:45:54 | INFO - Key: analyzer Value: standard
INFO | jvm 1 | 2005/07/14 11:45:54 | INFO - Key: maxMergeDocs Value:
INFO | jvm 1 | 2005/07/14 11:45:54 | INFO - Key: mergeFactor Value:
INFO | jvm 1 | 2005/07/14 11:45:54 | INFO - Key: minMergeDocs Value:
INFO | jvm 1 | 2005/07/14 11:45:55 | INFO -
INFO | jvm 1 | 2005/07/14 11:45:55 | INFO - Section: upd_svc
INFO | jvm 1 | 2005/07/14 11:45:55 | INFO - --------------------------------------
INFO | jvm 1 | 2005/07/14 11:45:55 | EGranUpdate startup Failed
INFO | jvm 1 | 2005/07/14 11:45:55 | WrapperManager.stop(9) called by thread: Wrapper-Connection
INFO | jvm 1 | 2005/07/14 11:45:55 | Send a packet STOP : 9
DEBUG | wrapperp | 2005/07/14 11:45:55 | read a packet STOP : 9
DEBUG | wrapper | 2005/07/14 11:45:55 | JVM requested a shutdown. (9)
DEBUG | wrapper | 2005/07/14 11:45:55 | wrapperStopProcess(9) called.
DEBUG | wrapper | 2005/07/14 11:45:55 | Sending stop signal to JVM
DEBUG | wrapperp | 2005/07/14 11:45:55 | send a packet STOP : NULL
INFO | jvm 1 | 2005/07/14 11:45:56 | Thread, Wrapper-Connection, handling the shutdown process.
INFO | jvm 1 | 2005/07/14 11:45:56 | Send a packet STOPPED : 0
DEBUG | wrapperp | 2005/07/14 11:45:56 | read a packet STOPPED : 0
DEBUG | wrapper | 2005/07/14 11:45:56 | JVM signalled that it was stopped.
INFO | jvm 1 | 2005/07/14 11:45:56 | Closing socket.
DEBUG | wrapperp | 2005/07/14 11:45:56 | socket read no code (closed?).
INFO | jvm 1 | 2005/07/14 11:45:56 | calling System.exit(9)
DEBUG | wrapper | 2005/07/14 11:45:56 | JVM process exited with a code of 9, however the wrapper exit code was already 9.
DEBUG | wrapper | 2005/07/14 11:45:56 | JVM exited normally.
STATUS | wrapper | 2005/07/14 11:45:57 | <-- Wrapper Stopped
ERROR | wrapper | 2005/07/14 11:45:58 | The eGranary Client Update Service service was launched, but failed to start.
________________________________________________________________
Sent via the WebMail system at mail.widernet.org
|