Some of the new sun blogs aren't fantastic, but a few from the kernel/solaris guys sure are. Check out this tip about nohup in Solaris 9. That's absolutely awesome; countless times I've kicked off a build (or a java server with inadequate start scripts...just in staging, never in prod) and forgotten to do something with it. nohup -p sweet.
What I'd really like to see in Solaris though, is a way for Java programs to behave more like regular daemons. The whole, background and redirect stderr/stdout or nohup java server processes is hokey. Or am I remembering that Solaris supports direct execution of java binaries somehow? Either way, I'd like to see a setproctitle(3) like call, because "weblogic-application-name" is a lot easier to find in a ps listing than "java -Dblahblah=blahblah -D blah-blahblah -ms128 -mx512 -". Simple process names, easy ways to create daemons (again, I can live even if they require tiny native stubs), possibly reliable jvm signal delivery.
Basically, Java daemons just don't behave like other programs, and usually how they do behave is much more inconvienent than typical unix daemons.
We run a bunch of weblogic instances on the same box, hosting about 10 different applications. That's about 20 java processes (admin servers) on the box, and finding out which one is listening on which port or which pid is which can be a nightmare. It usually ends up as a dance of trying to find the pid of the shell start script, then finding the VM that has that as a parent process. Pretty tough to do from a script. I've been thinking about using 'exec' in the shell so the pid stays the same and I can write it to a file, but then the ps listing is definitely not helpful...
I've been thinking about the "Java for daemons" problems a bit, and agree there's work needed here. One approach you could take in the meanwhile would be to launch your instances each in distinct projects. (See newtask(1), etc.) Then
$ pgrep -J project -x java
will return the PIDs of the JVMs running with that project ID. (And you can then use the project ID as part of your DTrace predicates, to watch only a particular instance.)
About finding processes: for java long names you can use /usr/ucb/ps -auxwww. This will give the full command name and arguments of the process including the class name which follows all the java options.
This is how I detect what each java process represents.
Thanks to both of you; those are awesome tips. I always forget about the ucb stuff, and I'll have to try out newtask(1).
This is Rob Meyer's weblog, a weblog focused on software development and system administration based on 10 years of experience. Want to explore further? You can find out more me or see the rest of my website.
Wondering if I've written on something in particular? Try searching:
You might want to take a look at some of the more requested postings (as judged by incoming traffic):
Want more? Subscribe to this site
or contact me at rob at big dis dot com.
See my writings on: