Automatic Starting Implementation Details for GlassFish 3.1
By ByronNevins on Feb 27, 2011
Process Nuts and Bolts
When you start a GlassFish 3.1 Server Service notice that there are 2 JVM processes running. The 2 process are these:
- The GlassFish Server
- A JVM running asadmin start-[local-instance|domain] --verbose
Why? We want to leverage the start command. Asadmin does a great deal of work for you when you start a server. The end-product of that work is mainly (but not only) the generation of a big complex JVM invocation command to start the server with. I could have implemented the Services to call asadmin and have asadmin exit. But then the Platform would see that asadmin exited and would report the service as "stopped". It would not know in the future when the server really stops.
When you start a server with the --verbose flag then the asadmin process waits for the server to die before exiting. When the server stops -- asadmin stops and the Platform will update the state to "stopped".
Note that restart-[domain|instance] will still work perfectly. In that case the server process dies but the asadmin process does not - not even for a moment. The platform will not "see" anything happening.
I discovered that there seems to be a special way to create services for every different flavor of Linux. And they are all different from each other. Basically all of these different ways end up with writing out special files into a special area. This one common denominator is to use the ancient UNIX way of setting up services which is, not surprisingly, editing lots of configuration files in a special area. Even the exact details on the special area is different among the different flavors. The code is flexible and will handle all known Linux flavors. The script can be found in /etc/init.d and links to it in the runlevel directories: /etc/init.d/rc?.d