in reply to Re^7: apache/perl caching problem
in thread apache/perl caching problem
I've implemented logging to view the pid's and yes, I'm seeing duplicate numbers. I can figure out how to view the version, full path & modification time of a different file, but how would you view the current file that is being executed? It looks like there are entries in the log for each execution. Would it be a safe assumption that each request is being handled by the server in question and not a problem with the network infrastructure?
"...By "standard CGI script" I mean a script that is read from disk and executed once for each request. An implication (or perhaps I should say assumption of mine) is that a perl interpreter is started for each request. This is in distinction to a script running in the context of mod_perl, FastCGI or some other context which transforms or encapsulates it in a persistent process that handles several requests before terminating..."
I *THINK* it's a "standard CGI script", but honestly, I'm not positive... This started out as a basic site someone else designed using login sessions. Since I've taken it over, I've added modules and additional sections to the site that are all blanketed under the session. I DO have "use CGI ':standard';" in my code. Does that make it a "standard CGI script"?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: apache/perl caching problem
by ig (Vicar) on May 04, 2010 at 21:05 UTC | |
The following is not a CGI script (it doesn't produce headers or any useful output) but it does show how you can log the name of the script, the directory it is located in, the process id it is running as and a version. You could incorporate something similar into your script.
Output from a few executions is as follows:
Note that the process id is different every time I run the script. If you add similar logging to your CGI script, you should be able to find the output in your website error log. Then, if you change the version number every time you change the script, you will have a record of what version was running and what process number was running it. You could change only the version number, just to make a change, then restart your server and check the logs for entries with the old version number appearing after the restart. If you find one, use the ps command to find out what the process is. This will help to isolate the problem. If you see a log entry on your server every time you submit a request from your browser, then it is reasonable to conclude the requests are making it to the server. There is still the possibility that the requests and/or responses are being modified between the server and browser. This is unusual, but it can happen. Don't worry about that yet. First, confirm that the server is running your script once for each request from the browser. Then confirm that each time your server runs your script it runs the "current" version. You might include the scripts version number in both the log and the response to the browser: you can put it in an HTML comment if you don't want it to be visible in the browser. Then you can check that the response received at the browser is from the current version of your script, or at least the same as the version that ran on the server. | [reply] [d/l] [select] |
by ksublondie (Friar) on May 04, 2010 at 23:24 UTC | |
Note that the lines with "modtime" are a pre-version 1.0. I performed a ps on the pid, however, I don't really know what I'm looking for. Here's the related output of "ps -ef": I was not able to detect any requests that were not logged on the server. | [reply] [d/l] [select] |
by ig (Vicar) on May 05, 2010 at 07:54 UTC | |
That looks very much like your server is running mod_perl or something with similar characteristics. For comparison, here are some logs from a couple of CGI scripts running on my system: one under mod_perl and the other not. Note that with mod_perl the same process id appears over and over while without mod_perl each request causes a new process to be started.
As all your requests are making it to the server and you can see the server running a mixture of versions of your script, you can forget about proxy servers. Previously you said that you sometimes saw responses from old versions of your script even after you restarted the server. I expect you will find you were mistaken (no offense intended) and that after you restart the server you no longer receive responses from versions from before the restart. When you restart your apache server, you should see entires similar to the following in your web server error log:
As for the ps output, the PID column shows the process ID, the STIME column shows when the process was started. In the sample you posted, all the processes are apache2 server processes. This confirms that it is apache2 that is running your CGI script and that it is doing so within the server process, as mod_perl does. Assuming you are running mod_perl (fairly certain at this point) then after each restart you should only see the latest version in the logs (and responses) and any new versions introduced since restarting the server. You can confirm your server is running mod_perl by checking the configuration for your website. You might find the mod_perl configuration manual helpful for understanding what to look for in your apache configuration file. | [reply] [d/l] [select] |
by Anonymous Monk on Sep 26, 2010 at 15:22 UTC | |