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

Job won't open the correct .env-file in Job? #84

Closed
christoph-werker opened this issue Aug 19, 2022 · 3 comments
Closed

Job won't open the correct .env-file in Job? #84

christoph-werker opened this issue Aug 19, 2022 · 3 comments

Comments

@christoph-werker
Copy link

Dear Community,

i'am dispatching a Job like this and in my job i want to Send an API-Request.

Job::dispatch($user)->delay(now()->addMinutes(60*3));

For the Request i need the Keys from the correct ENV file. But unfortunately the Job open the .env and not the .env.domain

$this->api = new Api(env('API_KEY'), env('API_DOMAIN'));
$this->api->action($this->var);

My Scheduler works with php artisan schedule:run --domain=domain

I hope that you understand my Question and know a solution.

@christoph-werker christoph-werker changed the title Won't open the correct .env-file in Job? Job won't open the correct .env-file in Job? Aug 19, 2022
@gecche
Copy link
Owner

gecche commented Aug 23, 2022

Hi,

but from which domain you dispatch the job? I ask you because to my knowledge there is no way to run a command/job under a certain domain/environment if you launch it from within the Laravel script ran under another domain/environment.

Cheers

Giacomo

@christoph-werker
Copy link
Author

Sorry for the delayed reply.

Then you pushed the job under the domain: DOMAIN_A, will the server execute the job with the .ENV from DOMAIN_A?

@gecche
Copy link
Owner

gecche commented Sep 15, 2022

yes... to my knowledge there is no way to "change the environment" from within the application itself. There is the need of some "machinery" outside the application which dispatch the jobs among the domains.

I think that in some way this is similar to another issue #14 which also could be solved only using a proper shell script.

I hope this helps... I close the issue for now... be free to reopen if you need

Cheers

Giacomo

@gecche gecche closed this as completed Sep 15, 2022
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

2 participants