-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathworker.php
38 lines (25 loc) · 878 Bytes
/
worker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
use Dotenv\Dotenv;
use Lefuturiste\Jobatator\Client;
require 'vendor/autoload.php';
if (file_exists('./.env')) {
(new Dotenv(__DIR__))->load();
}
$container = new DI\Container();
$builder = new DI\ContainerBuilder();
$builder->addDefinitions(include './src/config/config.php');
$builder->addDefinitions(include './src/config/containers.php');
$container = $builder->build();
if (getenv('SENTRY_DSN') !== null && is_string(getenv('SENTRY_DSN'))) {
Sentry\init(['dsn' => getenv('SENTRY_DSN') ]);
}
$client = $container->get(Client::class);
$client->setRootValue($container);
include 'src/handlers.php';
echo "> Worker initialized, now ready to work... \n";
if (boolval(getenv("SENTRY_ENABLE")))
$client->addExceptionHandler(fn ($e) => Sentry\captureException($e));
$client->addExceptionHandler(function ($e) {
throw $e;
});
$client->startWorker();