|
From: Christian M. <chr...@ta...> - 2012-05-09 03:52:13
|
Hello Daniel, I'm very sorry for the delay on getting back to you. The startup.timeout is basically to check that your application in the JVM got up and running. So if you use the WrapperSimpleApp, it will signal the Wrapper that the application has started once it called your main class. The WrapperSimpleApp by default doesn't wait for the main method to finish. If you add the waitForStartMain, it means that the WrapperSimpleApp will wait for your main method, but still since the main class was called successfully, it is periodically sending keep-alives to the Wrapper, so the Wrapper will not trigger the startup.timeout. It seems you want something where the keep alives are actually not sent and the main class can cause a timeout. Currently this is not possible with the WrapperSimpleApp, so you would have to create an implementation of the WrapperListener interface (integration method#2). http://wrapper.tanukisoftware.com/doc/english/integrate-listener.html Simplest way to is probably the following implementation: package <<<your-package>>>; import org.tanukisoftware.wrapper.WrapperManager; import org.tanukisoftware.wrapper.WrapperListener; import <<<your-main-class>>>; public class WrapperLauncher implements WrapperListener { /*--------------------------------------------------------------- * Constructors *-------------------------------------------------------------*/ private WrapperLauncher() { } /*--------------------------------------------------------------- * WrapperListener Methods *-------------------------------------------------------------*/ /** * The start method is called when the WrapperManager is signaled by the * native Wrapper code that it can start its application. This * method call is expected to return, so a new thread should be launched * if necessary. * * @param args List of arguments used to initialize the application. * * @return Any error code if the application should exit on completion * of the start method. If there were no problems then this * method should return null. */ public Integer start( String[] args ) { <<<your-main-class>>>.main( args ); return null; } /** * Called when the application is shutting down. The Wrapper assumes that * this method will return fairly quickly. If the shutdown code code * could potentially take a long time, then WrapperManager.signalStopping() * should be called to extend the timeout period. If for some reason, * the stop method can not return, then it must call * WrapperManager.stopped() to avoid warning messages from the Wrapper. * * @param exitCode The suggested exit code that will be returned to the OS * when the JVM exits. * * @return The exit code to actually return to the OS. In most cases, this * should just be the value of exitCode, however the user code has * the option of changing the exit code if there are any problems * during shutdown. */ public int stop( int exitCode ) { m_app.stop(); return exitCode; } /** * Called whenever the native Wrapper code traps a system control signal * against the Java process. It is up to the callback to take any actions * necessary. Possible values are: WrapperManager.WRAPPER_CTRL_C_EVENT, * WRAPPER_CTRL_CLOSE_EVENT, WRAPPER_CTRL_LOGOFF_EVENT, or * WRAPPER_CTRL_SHUTDOWN_EVENT * * @param event The system control signal. */ public void controlEvent( int event ) { if ( ( event == WrapperManager.WRAPPER_CTRL_LOGOFF_EVENT ) && ( WrapperManager.isLaunchedAsService() || WrapperManager.isIgnoreUserLogoffs() ) ) { // Ignore } else { WrapperManager.stop( 0 ); // Will not get here. } } /*--------------------------------------------------------------- * Main Method *-------------------------------------------------------------*/ public static void main( String[] args ) { // Start the application. If the JVM was launched from the native // Wrapper then the application will wait for the native Wrapper to // call the application's start method. Otherwise the start method // will be called immediately. WrapperManager.start( new WrapperLauncher(), args ); } } You would then change the wrapper.java.mainclass property to this class and drop the wrapper.app.parameter.1 value and move the others (if existing) up. Hope this helps you out. Best Regards, Christian Mueller Tanuki Software, Ltd. On Wed, May 2, 2012 at 12:38 AM, Constantin Daniel Becheanu < dre...@gm...> wrote: > Hi, > > I am trying to use wrapper.startup.timeout to timeout if my main does not > return in a specific time but it seem to have no effect( if i set it to 10 > s and my main takes 20 the script still completes successfully). > I am also setting > -Dorg.tanukisoftware.wrapper.WrapperSimpleApp.waitForStartMain=TRUE > > Is this property removed? > > Also is there is another way to fail if the main does not return in a > specific amount of time? > > > Thanks, > Daniel > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Wrapper-user mailing list > Wra...@li... > https://lists.sourceforge.net/lists/listinfo/wrapper-user > > |