-
Notifications
You must be signed in to change notification settings - Fork 99
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
Run commands with the --domain option from another command #18
Comments
Hi, sorry but as pointed out in the docs and in some previous issues, the Note that this is not a fault of the package, but it is due to how Laravel works and from a general viewpoint it is right. The only way to do what you want is to create an external script running an artisan command for each domain. I hope this helps and I close the issue. Cheers Giacomo |
Yes, your explanation helped me a lot, i managed to do what i needed. Thank you so much! |
Would you mind sharing the script/code that helped you to do it? Thanks |
Hi @newlaravelcoder , instead of create a command as in my first post, I run all the original commands with the parameter --domain. protected function schedule(Schedule $schedule)
{
$currentDomain = app()->domain();
$schedule->command('my:command --domain=' . $currentDomain)->dailyAt('1:00');
} I use php deployer to deploy my app, and this was the hardest thing, since I cannot run a simple command on all domains when deploying, so I created a custom recipe to run my commands: desc('Flush cache');
task('artisan:domains:cache:clear', function () {
foreach(get('domain_list') as $domain) {
run('{{bin/php}} {{release_path}}/artisan cache:clear --domain=' . $domain);
}
}); To make it work I added the entire domain list (as is it in config\domain) into my deploy.php file, this let me to read it during deploy with I hope I have been helpful, |
Hi, thank you for sharing your code.
Can you tell me where this code is to go... should I add this in laravel kernel file or it is a separate php file or a bash file to run in the terminal?
I am very new to laravel.. if you could tell me where these files to be created/updated and what command to type in terminal, that will be really helpful. Thank you again for sharing your code. |
I used the first piece of code I posted in my App\Console\Kernel (where you schedule your cron). Anyway you have to use the --domain parameter wherever you want to run a command on all domains. |
Thank you. |
Hi, i'm trying to create the command domains:migrate in order to run the artisan migrate command on all domains.
My command handle function is as follows:
When i run the command, i expect it to migrate to all 3 of my domains. But it fails and returns "nothing to migrate":
How can i create a command to execute migration on all my domains?
Thanks
The text was updated successfully, but these errors were encountered: