Jinetd: inetd for Java
What is it?
Jinetd does for TCP what servlet containers do for HTTP.
Isn't HTTP all that matters?
There are now Java servers for almost every network protocol: HTTP,
SMTP, IMAP, POP3, NNTP, DNS, SSH, CIFS/SMB, and plenty of others.
Using servers written in buffer-overflow-free languages is the most
important step towards maintaining network security and stopping
worms.
Huh?
Jinetd listens on the ports and interfaces you specify. When it
receives a connection, it loads the code designated to handle that
protocol and hands off the connection.
Isn't that trivially simple?
While jinetd is an extremely lightweight server, it allows multiple
different network protocol handlers to share the following facilities:
- No need for "start", "stop", or "reload" commands:
- Automatic reloading of services when a .jar, .class, or
.java file changes; just drop in the new code or
touch the jar file to trigger a restart.
- Services can add their own configuration files to the
"watched" list.
- Connections are always accepted immediately, even if the
service's code is still initializing itself. The
connection is paused until the service finishes loading,
at which point it is handled. No more "503 Server
Unavailable" messages for your users when you restart a
context; the user just experiences a brief delay before
the webpage loads.
- Edit-in-place development
- Automatic compilation of .java files for a service;
automatic reload once compilation completes
- Self-restart
- jinetd is usually invoked from a "respawn" line in /etc/inittab
- when it detects that its .jar files have been modified,
it exits and lets init respawn it
- when resources run critically low (ie low memory), jinetd
will abort the JVM and let init respawn it -- the only
way to kill runaway threads in Java.
- No configuration files to edit -- host-to-service and
port-to-service mappings are inferred from directory layout.
- Shared virtual host settings
- Arrange your content by (virtual) host rather than by service
-- for example, the HTTP and NNTP content for
"www.megacz.com" are kept side by side in
"/jinetd/host/com/megacz/HTTP" and
"/jinetd/host/com/megacz/NNTP".