Skip to content

Commit

Permalink
Merge pull request #8 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
fillup authored Nov 28, 2017
2 parents 5a0dae0 + 22a94eb commit a4df76d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
19 changes: 14 additions & 5 deletions application/frontend/web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,32 @@
/* NOTE: The composer autoloader will be one of the first things loaded by
* this required file. */
$config = require('../config/load-configs.php');
} catch (Sil\PhpEnv\EnvVarNotFoundException $e) {
$application = new yii\web\Application($config);
$application->run();
} catch (yii\web\HttpException $e) {

// Log to syslog (Logentries).
openlog('email-service', LOG_NDELAY | LOG_PERROR, LOG_USER);
syslog(LOG_CRIT, $e->getMessage());
closelog();

// Let the error bubble on up.
throw $e;

} catch (\Throwable $t) {

// Log to syslog (Logentries).
openlog('email-service', LOG_NDELAY | LOG_PERROR, LOG_USER);
syslog(LOG_CRIT, $t->getMessage());
closelog();

// Return error response code/message to HTTP request.
header('Content-Type: application/json');
http_response_code(500);
$responseContent = json_encode([
'name' => 'Internal Server Error',
'message' => $e->getMessage(),
'message' => $t->getMessage(),
'status' => 500,
], JSON_PRETTY_PRINT);
exit($responseContent);
}

$application = new yii\web\Application($config);
$application->run();
2 changes: 1 addition & 1 deletion application/run-cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ runny /data/yii migrate --interactive=0
# Dump env to a file
touch /etc/cron.d/email
env | while read line ; do
echo "$line" >> /etc/cron.d/email
echo "$line" >> /etc/cron.d/email
done

# Add env vars to idp-cron to make available to scripts
Expand Down
35 changes: 17 additions & 18 deletions application/yii
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,31 @@
* @license http://www.yiiframework.com/license/
*/

defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));

require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/common/config/bootstrap.php');

try {
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));

require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/common/config/bootstrap.php');

$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/common/config/main.php'),
require(__DIR__ . '/console/config/main.php')
);
} catch (Sil\PhpEnv\EnvVarNotFoundException $e) {
fwrite(STDERR, $e->getMessage() . PHP_EOL);
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);
} catch (\Throwable $t) {
fwrite(STDERR, $t->getMessage() . PHP_EOL);

openlog('email-service', LOG_NDELAY | LOG_PERROR, LOG_USER);
syslog(LOG_CRIT, $e->getMessage());
syslog(LOG_CRIT, $t->getMessage());
closelog();

exit(1);
}

$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);

0 comments on commit a4df76d

Please sign in to comment.