Remote Folding Status Servlet

A forum just for SPCR's folding team... by request.

Moderators: NeilBlanchard, Ralf Hutter, sthayashi, Lawrence Lee

Post Reply
dgouldin
Posts: 108
Joined: Fri Mar 14, 2003 1:31 pm
Location: Denton, TX
Contact:

Remote Folding Status Servlet

Post by dgouldin » Wed Apr 30, 2003 10:11 am

Is there any way for the folding client to pass information to other programs? I'm running Apache Tomcat and would like to create a servlet that would let me see my folding progress on the web so I can track it when I'm not at home.

If anybody wants to collaborate on this, let me know. I'll probably be doing some brainstorming on it for the next few days.

riffst3r
Posts: 221
Joined: Tue Apr 08, 2003 8:43 am
Contact:

Post by riffst3r » Wed Apr 30, 2003 12:27 pm

you can always have a webpage up with the logfile and WU data file (they're just text files) refreshing every 30seconds or so. that should be good.

EM accesses data in the same sort of way.

dgouldin
Posts: 108
Joined: Fri Mar 14, 2003 1:31 pm
Location: Denton, TX
Contact:

Post by dgouldin » Wed Apr 30, 2003 12:47 pm

That should work great! I can use Java file IO to test the modified date of the log and refresh its data when the log refreshes.

The only problem I can see coming up is if my servlet is trying to access the log at the same time it's being written ...

But that shouldn't happen very often if at all.

dgouldin
Posts: 108
Joined: Fri Mar 14, 2003 1:31 pm
Location: Denton, TX
Contact:

Post by dgouldin » Thu May 01, 2003 8:29 am

Update: I wrote a simple JSP to put the contents of the log on a web page. As soon as I ran it the first time, I couldn't finish any more frames in my FAH Console. Processor usage was still 100%, but the darn thing ran for 50 minutes without finishing a frame. I ran the graphical client to see if anything would be different there, and it locked up my machine. Upon rebooting everything seems to work.

I'm betting my problem is the one I mentioned earlier with 2 programs trying to access the file at the same time.

I'll probably make a temporary copy of the file when the JSP is accessed instead of opening the original log. Any other ideas/suggestions?

dukla2000
*Lifetime Patron*
Posts: 1465
Joined: Sun Mar 09, 2003 12:27 pm
Location: Reading.England.EU

Post by dukla2000 » Thu May 01, 2003 9:32 am

Did you see Electron Microscope seems to have a last page of options that seem to build a complete web page? And/or will even act as a web server? Haven't tried it myself.

dgouldin
Posts: 108
Joined: Fri Mar 14, 2003 1:31 pm
Location: Denton, TX
Contact:

Post by dgouldin » Thu May 01, 2003 9:43 am

I haven't looked at it. Creating a webpage would be nice ... I don't want it to run as a webserver because Tomcat is already taking port 80. Thanks for the tip!

PS - I got my JSP to work. Here's the code for anybody who's interested:

Edited to reflect FAHlog.txt:

Code: Select all

<%@ page language="java" import="java.io.*" %>
<HTML>
<HEAD>
<TITLE>Folding@Home Status</TITLE>
</HEAD>
<BODY>
<FONT FACE="Courier New" Size="-1">
<%
Runtime.getRuntime().exec("cmd /c copy \"C:\\Program Files\\Folding@Home\\FAHlog.txt\" \"C:\\Program Files\\Folding@Home\\templog.txt\"").waitFor();
File logFile = new File("C:\\Program Files\\Folding@Home\\templog.txt");
String tempStr = "  ";
try {
  BufferedReader in = new BufferedReader(new FileReader(logFile));
  while (tempStr != null){
    out.println(tempStr + "<BR>");
    tempStr = in.readLine();
  }
} catch (IOException e) {
}
logFile.delete();
%>
</FONT>
</BODY>
</HTML>
Really simple ... just displays the contents of the log file.
Last edited by dgouldin on Thu May 01, 2003 1:55 pm, edited 1 time in total.

Wrah
Patron of SPCR
Posts: 316
Joined: Thu Apr 10, 2003 1:56 am

Post by Wrah » Thu May 01, 2003 1:34 pm

Erm, I hate to say this to you but the filename of the logfile changes with every WU. :) FAH has a queue for 10 workunits, dunno why but it's there (in the graphical version, right-click on the icon, ->status->queue info). The 03 in the logfile's filename is slot# in the queue, it can range from 00 to 09.
You can use the FAHlog.txt file, perhaps your locking problem is gone then as well.

dgouldin
Posts: 108
Joined: Fri Mar 14, 2003 1:31 pm
Location: Denton, TX
Contact:

Post by dgouldin » Thu May 01, 2003 1:41 pm

Thanks for the heads up. That file has a lot more information I can do cool stuff with. It will have the same copy problem, but I'm not worried about that. I'll develop it over the next few days and let you guys know what I come up with.

Even if there is something already in Electron Microscope, using it wouldn't be nearly as much fun as this is. (aren't I a nerd?) :D

Wrah
Patron of SPCR
Posts: 316
Joined: Thu Apr 10, 2003 1:56 am

Post by Wrah » Thu May 01, 2003 1:47 pm

dgouldin wrote:Even if there is something already in Electron Microscope, using it wouldn't be nearly as much fun as this is. (aren't I a nerd?) :D
That's like buying a Dell! :mrgreen:

You may find the unitinfo.txt file useful too.

Post Reply