I have a Web app that contains a polling process (infinite while loop) that is started up by a Servlet when the Tomcat service starts up.
<load-on-startup>0</load-on-startup>
Which works fine.
If this were a Unix process then I could check it on the command line using:
ps -ef | grep <myProcess>
Is there anything (simple) that can be used in a Servlet to monitor the status of my Polling process?
EDIT
To clarify, all I really want to see is that the process is still running and hasn't stopped.
IMHO, you should not use a Servlet for that use case, but a ServletContextListener. In its contextInitialized(ServletContextEvent sce)
, the listener should :
Then, the listener could stop the polling thread in its contextDestroyed(ServletContextEvent sce)
, and any servlet (including JSPs) could get the state of the polling thread from the ServletContext.