Browse Source

attempt to disconnect and reconnect from the database between jobs

main
Aaron Parecki 8 years ago
parent
commit
957c09f237
3 changed files with 13 additions and 4 deletions
  1. +6
    -1
      lib/Telegraph/Webmention.php
  2. +5
    -3
      lib/helpers.php
  3. +2
    -0
      public/index.php

+ 6
- 1
lib/Telegraph/Webmention.php View File

@ -37,6 +37,8 @@ class Webmention {
}
public static function send($id, $client=false, $http=false) {
initdb();
$webmention = ORM::for_table('webmentions')->where('id', $id)->find_one();
if(!$webmention) {
echo 'Webmention '.$id.' was not found'."\n";
@ -98,7 +100,10 @@ class Webmention {
$webmention->save();
return self::updateStatus($webmention, $response['code'], $status, $response['body']);
$result = self::updateStatus($webmention, $response['code'], $status, $response['body']);
$pdo = ORM::get_db();
$pdo = null;
return $result;
}
}

+ 5
- 3
lib/helpers.php View File

@ -7,9 +7,11 @@ if(array_key_exists('ENV', $_ENV)) {
require(dirname(__FILE__).'/../config.php');
}
ORM::configure('mysql:host=' . Config::$db['host'] . ';dbname=' . Config::$db['database']);
ORM::configure('username', Config::$db['username']);
ORM::configure('password', Config::$db['password']);
function initdb() {
ORM::configure('mysql:host=' . Config::$db['host'] . ';dbname=' . Config::$db['database']);
ORM::configure('username', Config::$db['username']);
ORM::configure('password', Config::$db['password']);
}
function view($template, $data=[]) {
global $templates;

+ 2
- 0
public/index.php View File

@ -2,6 +2,8 @@
chdir('..');
include('vendor/autoload.php');
initdb();
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$router = new League\Route\RouteCollection;

Loading…
Cancel
Save