System.err/.out/.exit()

8 views
Skip to first unread message

Jetztgradnet

unread,
May 31, 2011, 3:55:00 AM5/31/11
to Erjang
Hi all,

I'm currently working on ewarp [*], a project to wrap Erlang apps into
a Java WAR file for execution in servlet containers such as Tomcat or
Jetty. This is also a good way to bring Erlang apps into the cloud,
e.g. in CloudFoundry or Amazon Elastic Beanstalk.

There are currently some limitations I would like to address:

Erjang is not currently designed to run embedded in other applications
where the lifecycle is determined by the hosting application. Examples
are applications like servlet containers or OSGi frameworks. The major
issues are calling System.exit() after shutting down Erjang using
ERT.shutdown() and a plethora of static variables and initializers.
Also there are plenty of System.{out|err}.println() calls scattered
throughout the code.

If accepted by Kresten, I would change all calls to System.{out|
err}.println() to use a logger. Although I'm not a fan of
java.util.logging, I would use this, as it doesn't introduce new
dependencies. But if the JCL API (which could also be provided by
SLF4J or other logging frameworks) is accepted as well, I would prefer
this. As most of these println()s seem to be helpers for the initial
implementation, would it be ok, to simply remove the commented calls?

Also I would like to get rid of calls to System.exit(). Any hints on
how to properly shut down Erjang, the Kilim scheduler, the thread
pools, etc. and release the drivers and other possibly statically
allocated objects or services? The basic idea is to allow reloading of
Erjang in a constantly running application such as a servlet container
or OSGi environment, which means, all classes, the corresponding class
loaders and all resources must be freed and be able to be re-allocated
(which happens in a new class loader, so static initializers would be
run again).

The last point is IO handling. ERT.set_stdio() allows to set streams
for input, output, and error, but the current implementation simply
overrides System.in/out/err. I would like to change this to Erjang
specific variables, which are then used by Erjang's IO. I guess the
relevant use of streams for IO are in FDDriverInstance,
ErlProc#display(), and Progress#activity()?

Regards,

Wolfgang


[*] https://github.com/jetztgradnet/ewarp
Reply all
Reply to author
Forward
0 new messages