View Single Post
Old 01-05-2005, 01:06 AM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Here is a tutorial I wrote to help you auto unlock and restart the process.

This tutorial assumes a *nix working environment with one spider process.

You will need to Google and/or mod the code as appropriate for your OS/setup.

First make a file containing '.' at /full/path/to/file.txt and set to 777 permission.

Next in spider.php find:
PHP Code:
if (USE_RENICE_COMMAND == 1) {
    print @
exec('renice 18 '.getmypid()).$br;

And afterwards add:
PHP Code:
$my_loc "/full/path/to/file.txt";
$my_file fopen($my_loc,"w+");
fputs($my_filegetmypid());
fclose($my_file); 
Then set the following script in a cron job and run it every so often.
PHP Code:
<?php
$my_loc 
"/full/path/to/file.txt";
$my_pid1 file_get_contents($my_loc);
$my_pid2 exec("ps -p $my_pid1 | grep \$? | awk '{print \$1}'");
if (
$my_pid1 != $my_pid2) {
/*
- Spider is either dead or index is completed
- Query the tempspider table or query the sites table
- Find num rows in tempspider or locked val in sites
- If num rows or locked equal zero index is completed
- Once completed there is nothing more to be done
- Otherwise the spider is dead so unlock the site
- Then restart the spidering process via cron
- You can do the code for this part ;)
*/
}
?>
Asking me why the spider dies is like asking me why there are dropped packets.

Maybe the MySQL connection hung, a server timed out somewhere, and so forth.

Something somewhere burped...
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote