views:

54

answers:

2

Suppose I have a simple daemon type script that I run on my webserver. I run it in a terminal, with gnu screen, so I can keep an eye on it. That works fine (incidentally, I use this trick).

But now suppose I'd like to make a web page where I can keep an eye on my script's output. What's the easiest way to do that?

Notes:

  • This is mainly for myself and a couple co-hackers so if websockets is the answer and it only works on Chrome or something, that's acceptable.
  • This question is asking something similar: http://stackoverflow.com/questions/1964494/how-to-make-all-connected-browsers. But I'm hoping for a simpler, quick-and-dirty solution, and especially a general way to quickly do this for any script I might want to keep an eye on from a browswer.
A: 

This looks really promising (thanks to my friend and hacker extraordinaire, David Yang):

http://blog.new-bamboo.co.uk/2009/12/7/real-time-online-activity-monitor-example-with-node-js-and-websocket

dreeves
+1  A: 

Let your daemon log output into a place that is accessible from a web script (Such as a database table), which can then display it. Have the webpage update once every few seconds. (You can get fancy at do it with XmlHttpRequest and Javascript, if you want)

Edit:

Simplest way to have a page update, is with a meta http-equiv="refresh" content="5"> tag. A bit more elegant is to use Javascript - You can use something like PeriodicalUpdater for jQuery.

These solutions are both polling techniques. There is a trick you can pull to make the event propagate instantly, called comet. But that's a bit more complicated, and frankly a poll probably suits your use case fine.

troelskn
Yeah, the daemon script is already running on the webserver and can send its output anywhere. So I guess the question is, can you spell out how to have a web page update every few seconds (or better, whenever the daemon outputs something new)?
dreeves