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

Question regarding running app + horizon + scheduler #61

Closed
tudorr89 opened this issue Feb 16, 2024 · 4 comments
Closed

Question regarding running app + horizon + scheduler #61

tudorr89 opened this issue Feb 16, 2024 · 4 comments
Labels
question Further information is requested

Comments

@tudorr89
Copy link

Hello!

First of all, congrats on this amazing project!

I have a very stupid question being kind of new to containerisation. I have a project running app, horizon and scheduler. What's the best approach to run the container(s)?

I've build the container using FrankenPHP. Do I need to run a container for each service (app,horizon,scheduler) separately? Or can it be done in a single container instance?

Best,
Tudor

@tudorr89 tudorr89 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 17, 2024
@smortexa
Copy link
Member

According to best practices, it is recommended to have one container for each process. However, for small to medium projects with low scales, I personally opt to use a single container to host all services.

@smortexa smortexa reopened this Feb 17, 2024
@smortexa smortexa added the question Further information is requested label Feb 17, 2024
@tudorr89
Copy link
Author

@smortexa thanks for the reply. I have initially build each container with the corresponding destination as per the instructions:

docker run -p <port>:80 --rm <image-name>:<tag>

docker run -e CONTAINER_MODE=horizon --rm <image-name>:<tag>

docker run -e CONTAINER_MODE=scheduler --rm <image-name>:<tag>

But when running jobs, i noticed a very strange error that was not occuring when running container queue:
Job is incomplete class: {"__PHP_Incomplete_Class_Name":"App\Jobs\UserActivatedNotificationJob","user":{"class":"App\Models\User","id":8,"relations":["breezySessions","post","book","tag"],"connection":"mysql","collectionClass":null}}

Tried changing queue driver to database or redis, only sync worked without this error. Thing is that in local dev env i tried both redis and database drivers and they work without any issues. I believe this is caused by the fact that I was running this three containers simultaneously.

Currently, I have opted to build the image using docker run -e WITH_HORIZON=true -p <port>:80 --rm <image-name>:<tag>

This way I run app + horizon in one container and finally I run docker run -e CONTAINER_MODE=worker -e -d WORKER_COMMAND="php /var/www/html/artisan scheduler:run" --rm <image-name>:<tag> to run the scheduler based on the initial image.

Not sure if this helps in any way, but I'm posting what I discovered.

Thanks again for the hard work!

@smortexa
Copy link
Member

Did you try these links?

laravel/framework#13222
https://stackoverflow.com/questions/74792738/laravel-job-error-job-is-incomplete-class

@tudorr89
Copy link
Author

I didn't have enough time to investigate this further, but I will try to create a staging environment from scratch and run the initial configuration.

Either way, so far so good. The initial question was about best practices and I thank you for the reply.

PS: A donate link would be useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants