On Wed, Mar 14, 2012 at 12:50:45PM +0000, Paul Singleton wrote:
> On 14/03/2012 01:37, Caldarale, Charles R wrote:
> 
> >> From: Warren Bell [mailto:warrenbe...@gmail.com]
> >> Subject: Initializing webapps in a certain order
> 
> >> Can you initialize webapps in a certain order ?
> 
> > Read the FAQ:
> > http://wiki.apache.org/tomcat/FAQ/Miscellaneous#Q27
> >
> > The primary reason is that the servlet spec requires that each webapp be 
> > self-contained and independent.
> 
> >> I have two apps, app1 and app2. app2 needs to access app1 during app2's
> >> initialization. I need app1 to be initialized first and be done before
> >> app2 starts to initialize.
> 
> > Sounds like a bad plan.
> 
> Sounds reasonable to me, that one service be designed to make use of 
> another service ;-)

It's also reasonable to design a service so that it doesn't have to
stall (or fail) *in the middle of startup* because a supporting
service is not running yet.  If they have to depend on each other,
they might just start anyway, keep trying to make contact, and fire a
message upon unreasonable delay.  Or just return an error status (and
hopefully an informative text) when dependent service A is asked for
something that can't be done without the help of supporting service B
which is not responding.  You probably want that sort of fail-soft
design anyway.  That would be "self-contained and independent" in my
book, since the app. can continue to operate and gives useful (if
undesired) responses regardless of what any other app. is doing.

Think of it as lazy initialization, driven by user requests instead of
startup code.  Startup of service or interactive programs should do
only what is absolutely necessary to get the app. into a state in
which it can respond, since there can be no guarantee that an
arbitrary request will *ever* succeed.

> We have OS services with explicit start-up dependencies, e.g. an issue 
> tracking system which uses an RDBMS, and I'd expect to be able to do 
> this with webapps.

Ah, but that's not the same mechanism.  There the OS works out the
dependency tree and doesn't start service A until supporting service B
indicates successful startup.  There's no such centralized dependency
analysis in a servlet container; the app.s start in any order the
container may choose and then stumble over missing dependencies.  I
think it could be argued that the servlet spec. makes startup ordering
by the container an explicit non-requirement, so you couldn't count on
it at another site or in another container version anyway.  If you're
going to make them dependent then you have to provide the whole
dependency resolution mechanism.

-- 
Mark H. Wood, Lead System Programmer   mw...@iupui.edu
Asking whether markets are efficient is like asking whether people are smart.

Attachment: pgpZJLaxkL0af.pgp
Description: PGP signature

Reply via email to