From 3ab183ef07d778d4d1a9f861a49b45063b50c8b4 Mon Sep 17 00:00:00 2001 From: Matt Henderson Date: Mon, 10 Feb 2014 10:41:50 -0500 Subject: [PATCH 1/2] Added swap space, entry to hosts file, and two npm packages to fix boot up. --- vagrant-setup.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vagrant-setup.sh b/vagrant-setup.sh index 6924549..bd73fb0 100755 --- a/vagrant-setup.sh +++ b/vagrant-setup.sh @@ -1,10 +1,18 @@ #!/bin/bash +# Create some swap space. +sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 +sudo /sbin/mkswap /var/swap.1 +sudo /sbin/swapon /var/swap.1 + +# Add the necessary entry/entries to the hosts file. +sudo echo 127.0.0.1 apiaxle.api.local >> /etc/hosts + # Install necessary packages sudo add-apt-repository -y ppa:chris-lea/node.js sudo apt-get update -y sudo apt-get install -y git python-software-properties build-essential libxml2-dev nodejs redis-server php5 php5-curl -sudo npm install -g apiaxle-base apiaxle-repl apiaxle-proxy apiaxle-api +sudo npm install -g sinon twerp apiaxle-base@1.10 apiaxle-repl@1.10 apiaxle-proxy@1.10 apiaxle-api@1.10 # Start ApiAxle processes apiaxle-proxy -p 3000 & From 47801efa20bdd7850b5e689a74d5c71bf94a4a1b Mon Sep 17 00:00:00 2001 From: Matt Henderson Date: Mon, 10 Feb 2014 11:15:11 -0500 Subject: [PATCH 2/2] Added check for NULL response when trying to decode the JSON data. --- src/ApiAxle/Shared/Utilities.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ApiAxle/Shared/Utilities.php b/src/ApiAxle/Shared/Utilities.php index 02024a4..f62ffd6 100644 --- a/src/ApiAxle/Shared/Utilities.php +++ b/src/ApiAxle/Shared/Utilities.php @@ -67,6 +67,16 @@ public static function callApi($apiPath, $method='GET', $data=null, $config) $request = HttpRequest::request($url, $method, $json_data, $headers, $config); if($request){ $results = json_decode($request); + + // If unable to decode the response as JSON... + if (is_null($results)) { + + // Throw an exception, suggesting to the user that the problem + // may be that ApiAxle is not running. + throw new \ErrorException('API did not return properly. ' . + 'Is ApiAxle running?'); + } + if($results->meta->status_code >= 200 && $results->meta->status_code < 300){ return $results->results; } elseif($results->meta->status_code >= 300 && $results->meta->status_code < 400){