-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Francis,
On 6/16/2011 5:03 PM, Francis GALIEGUE wrote: > On Thu, Jun 16, 2011 at 20:37, Christopher Schultz >> >> First off, the JVM provides no pure-Java way of letting a process go >> into the background. So, there's really no opportunity to do some work >> in Java and /then/ return to the calling process without terminating. >> >> Second, an OS return code requires a process termination, and you >> certainly don't want to terminate the JVM you've just started. >> > > I was actually wondering about these. I think I have my answer now :/ > Solutions in C or other languages are many to achieve that, Java has > none. Correct: native code has to be written. tc-native notwithstanding, the Tomcat team doesn't like to work with native code too much, and I can understand why: it's a total minefield. Different OS versions, different architectures, different c-library discrepancies, etc. Even if someone wrote something like this in native code, the result would be essentially a fork() call which would clone your JVM, which isn't going to be a fast process at that late stage of the game (in JVM time, that is). >> About the best we could do is change catalina.sh from roughly this: >> >> java org.apache.tomcat.Bootstrap >> logs/catalina.out & >> >> to this: >> >> java org.apache.tomcat.Bootstrap >> logs/catalina.out & >> >> tail -f logs/catalina.out | grep -m 1 "INFO: Server startup" >> >> exit 0 >> >> There are some problems with this approach: >> >> 1. It's not foolproof... if your server is insanely fast, it might >> start before tail | grep runs, and you might wait forever >> >> 2. The log messages are localized, so you'll have to use the proper >> localized message instead of just "INFO: Server startup" >> >> 3. This is so simple that you should be able to do it yourself >> >> Does this really need to be a part of the stock Tomcat? I'm not >> convinced that this exact solution would meet everyone's needs so it >> would need to be further customized, anyway. >> > > Yeah well, I can understand that since this is what I use right now. I > make it darn sure that my locale is set up OK, but then any different > logging configuration will defeat that. Which is why I am right now > switching over completely to the scenario where Tomcat only starts > with the manager webapp builtin and further webapps are deployed after > the initial startup. This still requires to parse the output of the > manager webapp, but at least it's better than the default :/ It would be somewhat easy to provide some more tools that could be used to script such things, such as a catalina.sh mode that would dump the expected text after a successful startup (e.g. it would print "INFO: Server startup"). That would let you do something like this: START_MESSAGE=`catalina.sh print-start-message` catalina.sh start tail -f logs/catalina.out | grep -m 1 "${START_MESSAGE}" exit 0 It's pretty easy to write a quickie class that grabs the right string from the right properties file given the locale, etc. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk36gCkACgkQ9CaO5/Lv0PBAywCgp38u7fc81d+0AqNQrdOaL458 T+0An0uZ+JrlTg3/TJnWg2nNDA4XfRSm =6tq9 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org