ccarney16 / pterodactyl-containers

Pterodactyl Panel within a docker container
231 stars 79 forks source link

Schedule & Email workers not working #135

Closed SerenModz21 closed 2 years ago

SerenModz21 commented 2 years ago

Hello, I recently got into dockerizing a pterodactyl panel, using IBRACORP's example (https://docs.ibracorp.io/pterodactyl-docker-1/pterodactyl-docker/docker-compose) as a guide. However, I have noticed that neither the scheduler nor email workers work correctly.

Email worker: I know this isn't working because when testing email settings, the test email gets sent out as expected. Where the issue comes into play is when inviting people to the panel or to a server. However, the emails of a user getting invited to the panel or being added to a server do not get sent. This is not the expected email worker behaviour.

Scheduler worker: When setting up schedules with multiple tasks, the first task in the schedule will run but the rest of them will get ignored. This is incorrect as the schedule should be running all tasks that have been added.

ccarney16 commented 2 years ago

The email worker has been something ive been tackling for some time, however the best method to fix this would be to use or setup an SMTP server. I use mailgun personally and pterodactyl does have a driver for that. As with the scheduler, im not too sure whats going on with that. I would suggest bringing it up to the ibracorp guys to see if they are missing anything, as I dont run the queue worker and cron in the same container. The docker-compose deployment setup has been working fine.

SerenModz21 commented 2 years ago

Thank you for your reply! I personally use SendGrid's SMTP Server for emails (my SendGrid credentials are correct due to the test button working but they still don't send )but for the scheduler worker, I will ask in the Ibracorp Discord server when I get home.

However, I did see that queue listeners are what send emails and run scheduled tasks. https://pterodactyl.io/panel/1.0/getting_started.html#queue-listeners. I saw both of them in the repo but maybe it's possible that or of them isn't being executed? I'm not too familiar with shell scripts so I may be incorrect.

SerenModz21 commented 2 years ago

It seems as though it's just the php artisan queue:work --queue=high,standard,low --sleep=3 --tries=3 (more info) command that is being executed in the background because if I exec into the docker container and run it myself, emails and schedules start working.

After a bit of research, the best way to do this would be to use a process manager, such as supervisord. An example can be found on the Docker documentation (https://docs.docker.com/config/containers/multi-service_container/) and in the official Dockerfile (https://github.com/pterodactyl/panel/blob/develop/Dockerfile).

The queue worker process can then be found in the supervisord.conf file: https://github.com/pterodactyl/panel/blob/develop/.github/docker/supervisord.conf#L27-L31

If I get the chance, I will personally try implementing supervisord and if successful, I will create a pull request for you to check out.

ccarney16 commented 2 years ago

I have avoided an init process because of how unreliable they can be and how much bloat they cause. My recommendation for my deployment has been to run cron/worker as independent containers, and have included start commands to execute them (p:cron, p:worker). If you want the full reference, you can always look at my compose configuration and get an idea.

SerenModz21 commented 2 years ago

Oh, ok. I will give your compose configuration a try. Thank you for your time!

Update: Creating separate containers for the worker and cron works perfectly!