[GRASS-user] The tomcat shut down when encounter some error grass commond

Glynn Clements glynn at gclements.plus.com
Sun Sep 20 18:17:28 EDT 2009


maven apache wrote:

> I am not exactly sure your meaning.
> What is short-lived process and what is persisitent process>?

By "short-lived non-interactive command", I'm talking about a typical
GRASS command: it reads parameters from the command line, performs
some processing, then exits. If there are any errors, then it just
exits, often without performing any significant processing.

By "persistent process" I'm talking about something like a daemon or a
GUI application, which performs multiple operations, and keeps
performing operations until it is specifically instructed to
terminate.

> Did you mean that if a process takes long time,then a error can terminate
> this thread?

It doesn't matter how long it takes; any error will normally terminate
the process. For a simple command, this isn't a problem; if the
library function didn't terminate the process, the main program would
terminate itself once the error was reported.

But for a persistent process which performs multiple operations, an
error would normally result in it aborting the current operation then
proceding to the next operation. This isn't possible if you're using
the GRASS libraries, as they don't generally permit the process to
continue after an error has occurred.

> and the web server is in the same thread,so it is shut down?
> If so ,does it mean that I should open a new thread for each grass commond?

This is about processes, not threads.

AFAIK, Tomcat behaves as a server, receiving requests from Apache and
passing them to Java modules for processing. If you use Tomcat to run
a module which uses GRASS library functions, if the GRASS library
function signals an error, it will call exit() which will terminate
the current process, i.e. it will terminate Tomcat.

If you want to avoid this, you need to process each request in a
separate *process*; a separate thread doesn't help, as exit()
terminates the process, not just a thread.

AFAICT, Java doesn't have an equivalent of fork() (which doesn't exist
on Windows); the normal mechanism for creating processes is with
Runtime.exec(). I have no idea whether this is even permitted from
within Tomcat, or whether there are any complications involved.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list