1

我有这个奇怪的错误。在我们的应用程序中,当用户创建或更新组时,我们将该组添加到 Solr 搜索索引或通过事件更新现有数据。它曾经工作正常,但现在它已经开始抛出这个错误。

数据库.php

'connections' => [

        'mongodb' => [
            'driver'   => 'mongodb',
            'host'     => env('MONGO_DB_HOST', 'localhost'),
            'port'     => env('MONGO_DB_PORT', 27017),
            'database' => env('MONGO_DB_DATABASE'),
            'username' => env('MONGO_DB_USERNAME'),
            'password' => env('MONGO_DB_PASSWORD'),
            'options' => [
                'db' => 'admin', // sets the authentication database required by mongo 3
            ]
        ],

        'advertiser' => [
            'driver'   => 'mysql',
            'host'     => env('ADVERTISER_DB_HOST', 'localhost'),
            'port'     => env('ADVERTISER_DB_PORT', 3306),
            'database' => env('ADVERTISER_DB_DATABASE'),
            'username' => env('ADVERTISER_DB_USERNAME'),
            'password' => env('ADVERTISER_DB_PASSWORD'),
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

        'sqlite' => [
            'driver' => 'sqlite',
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
        ],

        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

        'pgsql' => [
            'driver' => 'pgsql',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

    ],

监听器方法在GroupEventSubscriber.php

public function onNewGroupCreate(\App\Events\NewGroupCreate $event)
    {
        $group = $event->group;
        // this method adds the group to our solr index
        // i've commented out the method call after it started to throw error, but it still being called. 
        // the onGroupUpdate() method is similar to this
        //$this->addGroupToIndex($group);
    }

现在每次我创建或更新一个组时,这就是我得到的堆栈跟踪。注意:我已经在`onNewGroupCreate() 和 `onNewGroupCreate()中注释掉了addGroupToIndex()方法调用onGroupUpdate()

InvalidArgumentException:未配置数据库 [广告商]。在 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:239

堆栈跟踪:

0 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(158):

Illuminate\Database\DatabaseManager->getConfig('advertiser')

1 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(68):

Illuminate\Database\DatabaseManager->makeConnection('advertiser')

2 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(3351):

Illuminate\Database\DatabaseManager->connection('advertiser')

3 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(3317):

Illuminate\Database\Eloquent\Model::resolveConnection('advertiser')

4 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1861):

Illuminate\Database\Eloquent\Model->getConnection()

5 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1834):

Illuminate\Database\Eloquent\Model->newBaseQueryBuilder()

6 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1804):

Illuminate\Database\Eloquent\Model->newQueryWithoutScopes()

7 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(726):

Illuminate\Database\Eloquent\Model->newQuery()

8 /var/www/tagfi/api/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Eloquent/HybridRelations.php(26):

Illuminate\Database\Eloquent\Model->hasOne('App\Advertiser', 'id', 'place_id')

9 /var/www/tagfi/api/app/Group.php(67): App\Group->hasOne('App\Advertiser', 'id', 'place_id')

10 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2706):

应用\组->广告商()

11 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2679):

Illuminate\Database\Eloquent\Model->getRelationshipFromMethod('advertiser')

12 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2623):

Illuminate\Database\Eloquent\Model->getRelationValue('advertiser')

13 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(3466):

Illuminate\Database\Eloquent\Model->getAttribute('advertiser')

14 /var/www/tagfi/api/app/Listeners/GroupEventSubscriber.php(50): Illuminate\Database\Eloquent\Model->__get('advertiser')

15 /var/www/tagfi/api/app/Listeners/GroupEventSubscriber.php(90): App\Listeners\GroupEventSubscriber->addGroupToIndex(Object(App\Group))

16【内部函数】:App\Listeners\GroupEventSubscriber->onGroupUpdate(Object(App\Events\GroupUpdate))

17 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Events/CallQueuedHandler.php(42):

call_user_func_array(数组,数组)

18 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(73):

Illuminate\Events\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)

19 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(203):

照亮\队列\工作\工作->火()

20 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(152):

Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))

21 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(75):

Illuminate\Queue\Worker->runNextJob('redis', 'default', Object(Illuminate\Queue\WorkerOptions))

22 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(100):

Illuminate\Queue\Worker->daemon('redis', 'default', Object(Illuminate\Queue\WorkerOptions))

23 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(83):

Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'default')

24【内部函数】:Illuminate\Queue\Console\WorkCommand->fire()

25 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Container/Container.php(508):

call_user_func_array(数组,数组)

26 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Console/Command.php(169):

照亮\容器\容器->调用(数组)

27 /var/www/tagfi/api/vendor/symfony/console/Command/Command.php(261):

Illuminate\Console\Command->执行(对象(Symfony\Component\Console\Input\ArgvInput),对象(Symfony\Component\Console\Output\ConsoleOutput))

28 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Console/Command.php(155):

Symfony\Component\Console\Command\Command->运行(对象(Symfony\Component\Console\Input\ArgvInput),对象(Symfony\Component\Console\Output\ConsoleOutput))

29 /var/www/tagfi/api/vendor/symfony/console/Application.php(817): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput),

对象(Symfony\Component\Console\Output\ConsoleOutput))

30 /var/www/tagfi/api/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand),

对象(Symfony\Component\Console\Input\ArgvInput),对象(Symfony\Component\Console\Output\ConsoleOutput))

31 /var/www/tagfi/api/vendor/symfony/console/Application.php(116): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput),

对象(Symfony\Component\Console\Output\ConsoleOutput))

32 /var/www/tagfi/api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121):

Symfony\Component\Console\Application->运行(对象(Symfony\Component\Console\Input\ArgvInput),对象(Symfony\Component\Console\Output\ConsoleOutput))

33 /var/www/tagfi/api/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput),

对象(Symfony\Component\Console\Output\ConsoleOutput))

34 {主要}

我知道这太长了,但我似乎无法找到导致问题的原因。

4

0 回答 0