-
Notifications
You must be signed in to change notification settings - Fork 93
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
schedule:test does not print any output when running inside a php debian docker image #90
Comments
btw... // app/Providers/AppServiceProvider.php
public function boot(Request $request): void
{
\Laravel\Prompts\Prompt::fallbackWhen(true);
} is not working for me. there is no output, so to use "schedule:test" I first have to do a "schedule:list" and remember the number I want to call. |
Hey @michabbb, I'm having trouble replicating this one. I have Fedora and Podman, but I wouldn't think that matters. A few questions:
|
thanks for your feedback.
$ /usr/bin/konsole -v
konsole 21.12.3
Operating System: Kubuntu 22.04
KDE Plasma Version: 5.24.7
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.3
Kernel Version: 5.15.0-84-generic (64-bit)
Graphics Platform: X11
bool(true)
pardon.... how can I force laravel NOT using prompts ? |
Hi @michabbb, Your code for disabling prompts looks good to me. I've tested that code locally with your image and can confirm it enables Symfony's prompts instead. Because there's no output, it's hard to know whether Symfony or Laravel Prompts is waiting for input. You mentioned that you can run Are you able to perform the following test:
It's a long shot, but could you also please try updating Prompts (to v0.1.10)? |
Sorry for my late response, I am currently on vacation. I will try this weekend and let you know. |
@jessarcher oh dear.... i have found the problem 😕 I am using my own package to monitor cron-jobs. because your example code is working perfectly fine, I removed everything else, my package included. now I have to find out what exactly in my package causes the issue 🤔 😖 |
@jessarcher okay, i think i know where the problem is:
protected function schedule(Schedule $schedule): void
{
$schedule->command..................
Artisan::call('about'); // <---------- this line prevents any output
} it may look strange calling an artisan command at this point but I don´t know any other way to intercept into the scheduling process, that´s why I created my package as it is. to get a unique md5 hash of each of my schedule-commands I am calling maybe some more explanation: when a job gets scheduled by "schedule:run" my "monitor" method at the end of "Kernel::schedule" needs a unique md5 hash for each scheduled job. the way getting that custom "mutex" is to use a trait in each schedule-job so that a new parameter is available for the job: the problem I am facing: the md5 is based on the parameters that are used to call the artisan command. public function getCustomMutex(): string
{
$CommandOptions = $this->options();
unset($CommandOptions['mutex']);
$LaravelDefaultOptions = $this->getApplication()?->getDefinition()->getOptions();
$onlyMyOptions = array_diff_key($CommandOptions, $LaravelDefaultOptions);
$arguments = $this->arguments();
ksort($arguments);
ksort($onlyMyOptions);
return md5(
serialize([
'name' => $this->getName(),
'arguments' => $arguments,
'options' => $onlyMyOptions
]));
} at the time where I made the package I didn´t see any other way to get a unique hash of the job without calling the job 😏 i hope there is a way to fix that.... |
for now, i will try to NOT use any |
Hey @michabbb, Glad you figured it out! This sounds like the same issue as #74. If you're inside a command, you can use I wonder whether there is an event you could hook into instead? And if not, perhaps one could be added. |
@jessarcher i am sorry, but
protected function schedule(Schedule $schedule): void
{
$schedule->command..................
$this->call('about'); // <---------- this line prevents any output
} making a call at this point sadly doesn´t change anything 😕 is there any other thing that comes to your mind how I can reset the output after doing |
Hey @michabbb, I'm not sure I understand why you need to call the command with the Also, I'm not sure whether this would work for your use case, but instead of adding E.g. Event::macro('monitor', function ($output = true, $force = false) {
dump($output, $force);
dump($this->command);
dump(md5($this->command));
dump($this->mutexName());
$this->before(function () {
dump('before');
});
$this->after(function () {
dump('after');
});
}); And then the schedule would look something like this: protected function schedule(Schedule $schedule): void
{
$schedule->command('app:send-emails')
->everyMinute()
->monitor()
->description('Send emails every minute');
$schedule->command('app:send-emails --foo')
->everyMinute()
->monitor(output: false)
->description('Send emails every minute');
$schedule->command(SendEmails::class, ['--foo'])
->everyMinute()
->monitor(force: true)
->description('Send emails every minute');
} If I understand your package correctly, this should prevent the need to add traits and method calls to the schedule and commands. |
Going to close this for now but I'll have a think about the |
Thank so much for all that input. At the time I made that package I wasn't aware of the concept "macro" or at least never thought I could use it here. looks very interesting 😏 I already changed my package as u can see in the referring commit and I am using the "command" as my custom mutex. To be honest, the "--mutex" is a heck but that time, I didn't know it better 🤷♂️ 😏 I don't use Laravel's own mutex because it includes the cron-time, which makes sense for Laravel to handle "withoutOverlapping", but in my case I want something that is only unique to the job itself, without the cron. Because if a job runs at two different times, I still need to know it's the same job, so that forced me to create my own mutex in the first time 😏 I will check the macro idea, thanks a lot for pointing me to that direction 👍 And also thanks that you agree, that it would be nice to be able to make artisan calls inside cli calls in general 👍 |
Laravel Prompts Version
0.1.9
Laravel Version
10.25.1
PHP Version
8.2.8
Operating System & Version
linux
Terminal Application
xterm-256color (echo $TERM)
Description
i am running my php image
on a linux debian console like this:
docker run --rm -it -v ${PWD}:/app -w /app --init michabbb/php:8.2.bullseye php artisan schedule:test
and i don´t see any output. if I hit "enter" the first scheduled command will run. i looks like the cursor is working but
there is no output at all.
Steps To Reproduce
the dockerfile is very basic:
The text was updated successfully, but these errors were encountered: