开发者

Best way to program a server status feature

Some background information. - Running a java server on localhost - Running a webserver on localhost

I would like a webpage to have a 'server status' feature which lets me know whether the server is running or not. My question, what is the best way to do this?

  1. When I launch the java server, I write a flag in the database to signify that it is running.
  2. Javascript/PHP sockets to try and bind on the same port. (Not sure if possible yet)
  3. Shell script to locate the p开发者_开发百科rogram in the task list.

Thanks!


When I launch the java server, I write a flag in the database to signify that it is running.

would not be of much help if the server should segfault.

Maybe have a look at http://mmonit.com/monit/

what is pretty much what you are looking for


I suspect the simplest method is simply for your web service (backend) to try and connect to the port that your server is running on, and provide an automatically refreshing page that reports this status. If your server goes down then you'll get an faster notification than if you're polling (say) the process table.

Of course the fact that you can connect to the port doesn't really give you an indication of whether it's working other than it's opened a port (e.g. it may have no resources etc. to service requests) but it's a start.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜