lucatacconi / crunz-ui

Natural graphical user interface for Crunz (Crunzphp/Crunz). Allows users to setup tasks natively written in PHP and schedule them configuringing date and time of start, intervals and conditions of init and execution.
MIT License
12 stars 0 forks source link

DB stored tasks #12

Open tsmgeek opened 3 years ago

tsmgeek commented 3 years ago

Is your feature request related to a problem? Please describe. Can't be used if running on phpfpm server farm with separate backends or in docker deploys with no shared storage.

Describe the solution you'd like Store all takes in DB, deploy to tasks directory via cron script, also updates/deletes tasks as needed. This could then extend to allowing you to assign tasks to specific nodes or distribute tasks etc as possible future features.

Describe alternatives you've considered There are other apps that store crons in DB, just not the power of crunz and many are old and just support exec, not php functions.

Additional context N/a

lucatacconi commented 3 years ago

Hello, Tsmgeek, thank you for your suggestions.

First of all I would like to point out that Crunz-ui was created specifically to be used with Crunz. In the company where I work, we needed a quick workaround to allow even less skilled developers to load tasks into the system even without using ftp uploads.

It is interesting your proposal to use a DB to save the tasks and I imagine the logs too. However, you must also consider that Crunz-ui is only a graphical interface that uses Crunz as an engine to launch the programmed tasks. Crunz has a process that runs every minute. The process checks if there are tasks compatible with the launch date and time and, if any, runs them through the Php present in the system.

Saving the tasks in DB would mean, every minute, having to read all the tasks scheduled for that date and time and having to write them to the filesystem to prepare them for the Crunz process,but as you well know the file system writing procedure is considerably slow.

Could you suggest me the apps that save cron in db that you have experienced? Can we deepen your suggestion regarding distributed tasks and tasks assigned to specific nodes?

Regarding the problem you reported, I have no experience with Phpfpm server. However, we have installed Crunz-ui on a Docker. In that case we used an Apache+PHP Docker. On the Doker server we had scheduled a process to run every minute which called a sh script within the doker image:

/usr/bin/docker exec --user root app04 sh /in4/app04/http/crunz-ui/do_crontab.sh

The called script performed, on the Doker image, the following operation

#!/bin/bash
cd /var/www/crunz-ui-files/crunz/ 
/var/www/http/crunz-ui-files/crunz/crunz-ui.sh

Crunz-ui was then configured to use, for saving the logs, a folder configured as writable at the time of generating the logs.

I am available to verify the installation on your docker systems.

tsmgeek commented 3 years ago

Dkron/Rundek etc are some other packages that can execute code and get logs but not PHP specific.

We have a app that has a distributed load farm on phpfpm, it does not matter its phpfpm just that it runs across multiple servers and the crons are on several other servers depending on their tasks.

Splitting the 1:1 link between the UI and backend may be quite useful as then your UI can be on a public facing system but the backend "manager" sits on each of your registered cron servers which can stay private, it shuttles config/logs back and forth so the UI can operate independently elsewhere.