Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Handle google-cloud restructure for auto_prepend_file path #425

Merged
merged 9 commits into from
Mar 27, 2018
17 changes: 11 additions & 6 deletions php-base/stackdriver-files/enable_stackdriver_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ echo "Enabling stackdriver integration..."
# To start the batch daemon
cp /stackdriver-files/batch-daemon.conf /etc/supervisor/conf.d

if [ "${1}" = "--individual" ]; then
# For enabling automatic error reporting for google/cloud-error-reporting
cp /stackdriver-files/stackdriver-errorreporting-individual.ini ${PHP_DIR}/lib/conf.d
else
# For enabling automatic error reporting for google/cloud
cp /stackdriver-files/stackdriver-errorreporting.ini ${PHP_DIR}/lib/conf.d
# Detect the stackdriver prepend path
set +e
PREPEND_PATH=`php /stackdriver-files/locate_stackdriver_prepend.php`
set -e
if [ $? -ne 0 ]; then
if [ "${1}" = "--individual" ]; then
PREPEND_PATH="/app/vendor/google/cloud-error-reporting/prepend.php"
else
PREPEND_PATH="/app/vendor/google/cloud/src/ErrorReporting/prepend.php"
fi
fi
echo "auto_prepend_file=$PREPEND_PATH" > ${PHP_DIR}/lib/conf.d/stackdriver-prepend.ini
36 changes: 36 additions & 0 deletions php-base/stackdriver-files/locate_stackdriver_prepend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

$appDir = getenv('APP_DIR');
$appDir = $appDir ?: '/app';

// Use the application's vendor/autoload.php
require_once $appDir . '/vendor/autoload.php';

use Google\Cloud\ErrorReporting\Bootstrap;

if (class_exists(Bootstrap::class)) {
$reflection = new \ReflectionClass(Bootstrap::class);
if ($reflection->hasMethod('prependFileLocation')) {
echo Bootstrap::prependFileLocation() . PHP_EOL;
} else {
// default to same directory as the Bootstrap.php
echo realpath(dirname($reflection->getFileName()) . '/prepend.php') . PHP_EOL;
}
} else {
die('cannot find ErrorReporting\Bootstrap class');
}

This file was deleted.

2 changes: 0 additions & 2 deletions php-base/stackdriver-files/stackdriver-errorreporting.ini

This file was deleted.