Skip to content

Commit

Permalink
release fix
Browse files Browse the repository at this point in the history
  • Loading branch information
daveajones committed Nov 30, 2016
2 parents 9dce7be + 804c378 commit ef1aea8
Show file tree
Hide file tree
Showing 33 changed files with 3,801 additions and 164 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@

#### INSTALL:
The software will run on any unix-like system with a LAMP stack fairly easily, but it
installs and upgrades easiest on Unbuntu LTS 12, 14, etc. That's what is assumed in the install
installs and upgrades easiest on Unbuntu LTS 12, 14 or 16 etc. That's what is assumed in the install
documentation. Running on any other system will require installing by hand, which is
not hard.

Although the system will run without Amazon S3 configured, it loses a lot of the best
functionality. Amazon S3 is really cheap. You should do it. :-)

Ubuntu 12 LTS [on Amazon Ec2]:
Example: Ubuntu 12,14,16 LTS [on Amazon Ec2]:

1. [Launch an "small" Ubuntu 12 LTS ec2 instance.]
2. [Create an Elastic IP and assign it to your instance.]
Expand Down
71 changes: 71 additions & 0 deletions bin/buildsearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<? include get_cfg_var("cartulary_conf") . '/includes/env.php'; ?>
<? include "$confroot/$templates/php_bin_init.php" ?>
<?

//Let's not run twice
if (($pid = cronHelper::lock()) !== FALSE) {

//If this is being run as an upgrade
$action = "";
if (in_array("resume", $argv)) {
$action = "resume";
}
$startid = 0;
foreach( $argv as $arg) {
if(is_numeric($arg)) {
$startid = $arg;
break;
}
}


loggit(3, "Building search maps...");
echo "Building search maps...\n";
$tstart = time();

echo "Ignore: " . print_r($cg_search_map_ignore, TRUE) . "\n";

//Get all of the feed items in the system
$count = 0;
$items = get_all_feed_item_ids();
$icount = count($items);
echo "Got: [$icount] items...\n";

//Loop and map each item into the search tables
foreach ($items as $itm) {
if ($action == "resume" && $startid != 0) {
if($itm < $startid) continue;
echo "Skipping item [$itm] cause resume.";
}

echo "Mapping item($itm): [$count / $icount].\n";

$item = get_feed_item($itm);

$host = parse_url($item['url'], PHP_URL_HOST);
map_feed_item($item['id'], $item['title'] . " " . $item['description'] . " " . $host);

if ($count % 100 == 0) {
$sofar = time() - $tstart;
echo " [$sofar] seconds elapsed so far.\n";
}

unset($item);

$count++;
}

//Build search word counts
echo "Calculating word maps.\n";
calculate_map_word_counts();
calculate_map_word_today_counts();

//Calculate how long it took
$took = time() - $tstart;
echo "It took: [$took] seconds to build search maps.\n";
loggit(1, "It took: [$took] seconds to build search maps.");

//Release the lock
cronHelper::unlock();
}
exit(0);
37 changes: 22 additions & 15 deletions bin/feedscan.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
<? include "$confroot/$templates/php_bin_init.php" ?>
<?
//Let's not run twice
if ( ( $pid = cronHelper::lock() ) !== FALSE ) {
if (($pid = cronHelper::lock()) !== FALSE) {

//Track the river scan time
$tstart = time();

//Get the feed list
//Checking a single feed?
if ( isset($argv[1]) && !empty($argv[1]) ) {
if (isset($argv[1]) && !empty($argv[1])) {
$feed = get_feed_info(feed_exists($argv[1]));
$feeds = array( $feed );
$feeds = array($feed);
} else {
$feeds = get_updated_feeds();
}
Expand All @@ -27,7 +27,7 @@
$ccount = 0;
$ncount = 0;
$newitems = 0;
foreach ( $feeds as $feed ) {
foreach ($feeds as $feed) {
loggit(1, "Checking feed: [" . $feed['title'] . " | " . $feed['url'] . "]...");
echo "Checking feed: [" . $feed['title'] . " | " . $feed['url'] . "]...\n";

Expand All @@ -37,45 +37,52 @@
//Parse the feed and add new items to the database
loggit(1, "Checking feed: [ $ccount | " . $feed['title'] . " | " . $feed['url'] . "].");
$result = get_feed_items($feed['id']);
if ( $result == -1 ) {
if ($result == -1) {
loggit(1, "Error getting items for feed: [" . $feed['title'] . " | " . $feed['url'] . "]");
echo " Error getting items for feed: [" . $feed['title'] . " | " . $feed['url'] . "]\n";
} else if ( $result == -2 ) {
} else if ($result == -2) {
loggit(1, "Feed: [" . $feed['title'] . " | " . $feed['url'] . "] has no items.");
echo " Feed is empty.\n";
} else if ( $result == -3 ) {
} else if ($result == -3) {
loggit(1, "Feed: [" . $feed['title'] . " | " . $feed['url'] . "] is current.");
echo " Feed is current.\n";
} else {
loggit(3, "Feed: [" . $feed['title'] . " | " . $feed['url'] . "] updated.");
loggit(1, "Feed: [" . $feed['title'] . " | " . $feed['url'] . "] updated.");
echo " Feed updated.\n";
$ncount++;
$newitems += $result;
}

$ccount++;

echo " It took " . ( time() - $fstart ) . " seconds to scan this feed.\n";
loggit(1, "It took [" . ( time() - $fstart ) . "] seconds to scan this feed.");
echo " It took " . (time() - $fstart) . " seconds to scan this feed.\n";
loggit(1, "It took [" . (time() - $fstart) . "] seconds to scan this feed.");
echo "\n";

//We stop scanning if this scan has taken longer than expected
if ( ( time() - $tstart ) > $totaltime ) {
if ((time() - $tstart) > $totaltime) {
loggit(3, "Stop scan because it took longer than the expected: [$totaltime] seconds.");
break;
}

//We stop scanning once we hit our feed count limit for this pass
if ( $ccount >= $scancount ) {
if ($ccount >= $scancount) {
break;
}
}
echo "\n";

//Rebuild the v2 search map counts if v2 enabled
if ($cg_search_v2_enable) {
loggit(3, "Rebuilding search word counts.");
calculate_map_word_counts();
calculate_map_word_today_counts();
}

//Calculate time took to scan the river
loggit(3, "It took " . ( time() - $tstart ) . " seconds to scan [$ccount] of [$totalfeeds] feeds.");
loggit(3, "It took " . (time() - $tstart) . " seconds to scan [$ccount] of [$totalfeeds] feeds.");
loggit(3, "Total checked: [$ccount]. Updated: [$ncount]. New items: [$newitems].");
echo " It took " . ( time() - $tstart ) . " seconds to scan [$ccount] of [$totalfeeds] feeds.\n";
echo " It took " . (time() - $tstart) . " seconds to scan [$ccount] of [$totalfeeds] feeds.\n";
echo "Total checked: [$ccount]. Updated: [$ncount]. New items: [$newitems].\n";


Expand All @@ -85,4 +92,4 @@
//Remove the lock file
cronHelper::unlock();
}
exit( 0 );
exit(0);
Loading

0 comments on commit ef1aea8

Please sign in to comment.