Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'ErrorException' with message 'Use of undefined constant STDOUT - assumed 'STDOUT' #42

Closed
dwightwatson opened this issue May 23, 2014 · 22 comments

Comments

@dwightwatson
Copy link

I'm just setting up Dispatcher to take over from our cron jobs but I'm seeing this error in my logs whenever a scheduled command is meant to run. The command does not end up completing any of the tasks it was meant to.

Any ideas what could be going wrong here?

[2014-05-23 12:28:02] production.ERROR: exception 'ErrorException' with message 'Use of undefined constant STDOUT - assumed 'STDOUT'' in /home/laravel/vendor/wp-cli/php-cli-tools/lib/cli/Shell.php:51
Stack trace:
#0 /home/laravel/vendor/wp-cli/php-cli-tools/lib/cli/Shell.php(51): Illuminate\Exception\Handler->handleError(8, 'Use of undefine...', '/home/laravel/...', 51, Array)
#1 /home/laravel/vendor/wp-cli/php-cli-tools/lib/cli/Table.php(69): cli\Shell::isPiped()
#2 [internal function]: cli\Table->__construct(NULL, NULL, NULL)
#3 /home/laravel/bootstrap/compiled.php(254): ReflectionClass->newInstanceArgs(Array)
#4 /home/laravel/bootstrap/compiled.php(212): Illuminate\Container\Container->build('Indatus\\Diipatt...', Array)
#5 /home/laravel/bootstrap/compiled.php(586): Illuminate\Container\Container->make('Indatus\\Diipatt...', Array)
#6 /home/laravel/bootstrap/compiled.php(283): Illuminate\Foundation\Application->make('Indatus\\Diipatt...')
#7 /home/laravel/bootstrap/compiled.php(266): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#8 /home/laravel/bootstrap/compiled.php(253): Illuminate\Container\Container->getDependencies(Array, Array)
#9 /home/laravel/bootstrap/compiled.php(212): Illuminate\Container\Container->build('Indatus\\Diipatt...', Array)
#10 /home/laravel/bootstrap/compiled.php(586): Illuminate\Container\Container->make('Indatus\\Diipatt...', Array)
#11 /home/laravel/bootstrap/compiled.php(3163): Illuminate\Foundation\Application->make('Indatus\\Diipatt...')
#12 /home/laravel/vendor/indatus/dispatcher/src/Indatus/Dispatcher/ConfigResolver.php(50): Illuminate\Support\Facades\Facade::__callStatic('make', Array)
#13 /home/laravel/vendor/indatus/dispatcher/src/Indatus/Dispatcher/ConfigResolver.php(50): Illuminate\Support\Facades\App::make('Indatus\\Diipatt...')
#14 /home/laravel/vendor/indatus/dispatcher/src/Indatus/Dispatcher/ServiceProvider.php(53): Indatus\Dispatcher\ConfigResolver->resolveServiceClass()
#15 /home/laravel/bootstrap/compiled.php(240): Indatus\Dispatcher\ServiceProvider->Indatus\Dispatcher\{closure}(Object(Illuminate\Foundation\Application), Array)
#16 /home/laravel/bootstrap/compiled.php(212): Illuminate\Container\Container->build(Object(Closure), Array)
#17 /home/laravel/bootstrap/compiled.php(586): Illuminate\Container\Container->make('Indatus\\Diipatt...', Array)
#18 /home/laravel/bootstrap/compiled.php(283): Illuminate\Foundation\Application->make('Indatus\\Diipatt...')
#19 /home/laravel/bootstrap/compiled.php(266): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#20 /home/laravel/bootstrap/compiled.php(253): Illuminate\Container\Container->getDependencies(Array, Array)
#21 /home/laravel/bootstrap/compiled.php(212): Illuminate\Container\Container->build('Indatus\\Diipatt...', Array)
#22 /home/laravel/bootstrap/compiled.php(586): Illuminate\Container\Container->make('Indatus\\Diipatt...', Array)
#23 /home/laravel/bootstrap/compiled.php(3163): Illuminate\Foundation\Application->make('Indatus\\Diipatt...')
#24 /home/laravel/vendor/indatus/dispatcher/src/Indatus/Dispatcher/ServiceProvider.php(81): Illuminate\Support\Facades\Facade::__callStatic('make', Array)
#25 /home/laravel/vendor/indatus/dispatcher/src/Indatus/Dispatcher/ServiceProvider.php(81): Illuminate\Support\Facades\App::make('Indatus\\Diipatt...')
#26 /home/laravel/bootstrap/compiled.php(125): Indatus\Dispatcher\ServiceProvider->Indatus\Dispatcher\{closure}(Object(Illuminate\Foundation\Application))
#27 /home/laravel/bootstrap/compiled.php(240): Illuminate\Container\Container->Illuminate\Container\{closure}(Object(Illuminate\Foundation\Application), Array)
#28 /home/laravel/bootstrap/compiled.php(212): Illuminate\Container\Container->build(Object(Closure), Array)
#29 /home/laravel/bootstrap/compiled.php(586): Illuminate\Container\Container->make('command.schedul...', Array)
#30 /home/laravel/bootstrap/compiled.php(363): Illuminate\Foundation\Application->make('command.schedul...')
#31 /home/laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php(134): Illuminate\Container\Container->offsetGet('command.schedul...')
#32 /home/laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php(149): Illuminate\Console\Application->resolve('command.schedul...')
#33 /home/laravel/bootstrap/compiled.php(2912): Illuminate\Console\Application->resolveCommands(Array)
#34 [internal function]: Illuminate\Support\ServiceProvider->Illuminate\Support\{closure}(Object(Illuminate\Console\Application))
#35 /home/laravel/bootstrap/compiled.php(5805): call_user_func_array(Object(Closure), Array)
#36 /home/laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php(71): Illuminate\Events\Dispatcher->fire('artisan.start', Array)
#37 /home/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php(45): Illuminate\Console\Application->boot()
#38 /home/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php(57): Illuminate\Foundation\Artisan->getArtisan()
#39 /home/laravel/bootstrap/compiled.php(3163): Illuminate\Foundation\Artisan->__call('add', Array)
#40 /home/laravel/bootstrap/compiled.php(3163): Illuminate\Foundation\Artisan->add(Object(Books\AmazonOfferCommand))
#41 /home/laravel/app/start/artisan.php(14): Illuminate\Support\Facades\Facade::__callStatic('add', Array)
#42 /home/laravel/app/start/artisan.php(14): Illuminate\Support\Facades\Artisan::add(Object(Books\AmazonOfferCommand))
#43 /home/laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php(63): require('/home/laravel/...')
#44 /home/laravel/vendor/laravel/framework/src/Illuminate/Console/Application.php(33): Illuminate\Console\Application->boot()
#45 /home/laravel/artisan(45): Illuminate\Console\Application::start(Object(Illuminate\Foundation\Application))
#46 {main} [] []
@bkuhl
Copy link
Member

bkuhl commented May 23, 2014

The error is coming from a dependency of Dispatcher. Can you post your schedule() that is throwing this error?

@bkuhl
Copy link
Member

bkuhl commented May 25, 2014

It looks like there also might be an issue with a dependency here. The stack trace shows Indatus\\Diipatt..., whereas the namespace of this package is Indatus\Dispatcher

@dwightwatson
Copy link
Author

Apologies, I was without a computer over the weekend.

Here are the registered schedule methods, I will try disabling them all and then re-enabling them one by one to see if that changes anything. Note that these are all from different commands.

/**
 * When a command should run.
 *
 * @param Scheduler $scheduler
 * @return \Indatus\Dispatcher\Scheduling\Schedulable
 */
public function schedule(Schedulable $scheduler)
{
    // Run on Friday at 9am.
    return $scheduler->daysOfTheWeek(Scheduler::FRIDAY)->hours(9)->minutes(0);
}

/**
 * When a command should run.
 *
 * @param Scheduler $scheduler
 * @return \Indatus\Dispatcher\Scheduling\Schedulable
 */
public function schedule(Schedulable $scheduler)
{
    // Run every day at 9am.
    return $scheduler->daily()->hours(9)->minutes(0);
}

/**
 * When a command should run.
 *
 * @param Scheduler $scheduler
 * @return \Indatus\Dispatcher\Scheduling\Schedulable
 */
public function schedule(Schedulable $scheduler)
{
    // Run every day at 3am.
    return $scheduler->opts([
            'count' => 5000
        ])->daily()
        ->hours(3)
        ->minutes(0);
}

/**
 * When a command should run.
 *
 * @param Scheduler $scheduler
 * @return \Indatus\Dispatcher\Scheduling\Schedulable
 */
public function schedule(Schedulable $scheduler)
{
    // Run every day at 3am.
    return $scheduler->daily()->hours(3)->minutes(0);
}

@dwightwatson
Copy link
Author

I disabled all the commands (using isEnabled(), if that makes a difference or not) and am still seeing the same issue. Might I need to actually remove the other commands/unregister them from Artisan and test again?

@bkuhl
Copy link
Member

bkuhl commented May 26, 2014

If you could try unregistering them one by one that would be great. Is this running on Windows or Linux?

If you could also verify the imports on your commands by looking for Indatus\\Diipatt to figure out where that's coming from as well.

@dwightwatson
Copy link
Author

Will do, I'll do it tomorrow when I'm back at work. This is running on a Linux machine, using cPanel.

I'll double-check the imports as well. To be honest, I actually saw an example recently with some other code where the namespace was being all skewed, I never discovered why but it was unrelated to the problem. Really curious.

@bkuhl
Copy link
Member

bkuhl commented Jun 1, 2014

Did you have a chance to review this?

@dwightwatson
Copy link
Author

Apologies, was out of town for the remainder of the week. I'm going to try again by unregistering the commands one by one tomorrow and will report back.

@bkuhl
Copy link
Member

bkuhl commented Jun 20, 2014

Any luck on the source of the issue?

@bkuhl bkuhl closed this as completed Jun 23, 2014
@erixx104
Copy link

erixx104 commented Jul 6, 2014

I have the same error, mentioned above ('Use of undefined constant STDOUT - assumed 'STDOUT'), if I perform ANY Artisan:call('XY') from somewhere in my application. Everything goes fine if I remove Indatus/Dispatcher from composer.json and the ServiceProvider from the providers-array.

I've tested it with a newly created and empty artisan command.

Any idea?

@DGTnt
Copy link

DGTnt commented Jul 7, 2014

For those who're still suffering.. I was able to solve that Issue by putting those queue's inside the cron manually. I've been suffering that issue each time when I made artisan following up the queue untill I decided to make the queue's run by cron.

Somehow or something is blocking that php shell to act with the terminal which provides the error. When manually steering the queue via cron, it doesn't happens.

@bkuhl
Copy link
Member

bkuhl commented Jul 12, 2014

PHP only defines STDOUT when being run in cli. Seeing as Artisan::call() is likely not being executed via cli I think that makes sense. This error is coming from the php-cli dependency that Dispatcher only uses in the Cron driver when printing a cron summary: https://github.com/Indatus/dispatcher/blob/master/src/Indatus/Dispatcher/Drivers/Cron/ScheduleService.php . Are you running Artisan::call() on a command scheduled with dispatcher?

It'd be helpful to see a project where this error occurs. Is it possible for you to grant me access or send some source code privately via email?

@erixx104
Copy link

I've just sent you an email with the url.
Thx for help.

@bkuhl
Copy link
Member

bkuhl commented Jul 12, 2014

I haven't received that email.

@bkuhl bkuhl reopened this Jul 12, 2014
@bkuhl bkuhl closed this as completed Jul 12, 2014
@erixx104
Copy link

Then I've got the wrong address. I took the one, mentioned at the end of the instruction slides.

@bkuhl
Copy link
Member

bkuhl commented Jul 12, 2014

Indatus is in the process of moving some servers this weekend which may be
affecting my email. Can you send it to benkuhl@gmail.com ?

On Sat, Jul 12, 2014 at 2:00 PM, erixx104 notifications@github.com wrote:

Then I've got the wrong address. I took the one, mentioned at the end of
the instruction slides.


Reply to this email directly or view it on GitHub
#42 (comment).

Ben Kuhl

@bkuhl
Copy link
Member

bkuhl commented Jul 12, 2014

I've submitted a pull request to php-cli-tools to resolve this: wp-cli/php-cli-tools#57

@bkuhl
Copy link
Member

bkuhl commented Jul 14, 2014

I've pushed an update to the develop branch that I believe will resolve this. Please update your composer to use this branch and see how that works for you.

b31007b

@erixx104
Copy link

Your update works. Artisan::call() works without problems. Scheduled Jobs still running. Everything seems to be fine to me!

@bkuhl bkuhl reopened this Jul 14, 2014
@bkuhl
Copy link
Member

bkuhl commented Jul 14, 2014

Excellent! Since several of you guys were having this issue, can I get a 2nd confirmation from someone that this resolves the issue?

@spamoom
Copy link

spamoom commented Jul 17, 2014

I can confirm this has been fixed in the develop branch

@bkuhl
Copy link
Member

bkuhl commented Jul 17, 2014

Thanks!

Issue is resolved with the latest release: https://github.com/Indatus/dispatcher/releases/tag/v1.3.1

@bkuhl bkuhl closed this as completed Jul 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants