-
Notifications
You must be signed in to change notification settings - Fork 17
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 script immediatly after trigger #91
Comments
files_accesscontrol addresses a very different use case. workflow_script always triggers the script per background job, currently. |
Yes, it's a different use case. I did not find a better solution. The currently lock strategie is unable to handle locks and migrations of multiple users on multiple access ways to the files (Web, WebDAV, Client). |
files_lock could be extended to offer a flow actions itself and act accordingly. |
Putting aside the specific use case above, it would be handy to run scripts immediately after the trigger. When I discovered this app I thought "great, I can do faster push processing instead of pull processing". But this app at the moment just queues itself on the pull-queue that is cron. It would be almost as easy to write my own cronjobs that just enforce their own quit-early event filtering and have the same performance. In my case I am trying to provision some credentials when new users get created, and I think I can do it with this app, but I don't want my HR people to be waiting around for 5 minutes for cron to wake up and run the triggers when they're trying to onboard someone. My workaround for the moment is replace this cronjob
with
which I expect will have some negative consequences down the road. |
Currently easiest thing is having a timer/cron/daemon running that looks for registered jobs and executes them. The latter can be achieved with something like: php occ background-job:list --output json --class 'OCA\WorkflowScript\BackgroundJobs\Launcher' | jq -r .[].id | xargs -n1 php occ background-job:execute |
What's the reason (the background) that the workflow job(s) are not executed immediately? Just an idea: As soon as the file is touched inotify comes into action and execute the workflow scripts. The directory that could be used as an example is, I think, Perhaps, multiple files must be created with each file containing the job-name-id that is to be executed. When that particular job has been executed the related file must be removed. Would something like this be possible (this requires setting up inotify, but with a good procedure that may not be too difficult)? |
Hmmm, I think it should just run the "nextcloud-x.y.z/cron.php" job, that is now run from the cronjob. |
Yes, and potential Exceptions that might be thrown.
You could watch the database file for oc_jobs. |
How would that be done? inotify (inode notification) is a buildin Linux kernel module that gets triggered when a file is created, modified, deleted, etc. There is no polling needed. One sets a watch on the directory and as soon as a file in the directory is added, modified or deleted, the watcher activates the specified/configured script. The script can then start to look for Nextcloud jobs. And as soon as these appear in the Nextcoud table ( I assume oc_jobs), the jobs can be processed (occ cron background-job:list....) So yes, use oc_jobs but after inotify is triggered by Nextcloud. |
May depend on the database you use, but for instance MySQL/MariaDB stores each table in a single file, so you can watch this one for changes. Something like |
Should each job in the oc_jobs.ibd table result in a trigger, or should there only be a trigger for certain tasks/jobs in the script workflow? Would a DB engine independent solution, be possible and perhaps would that be better? |
For sqlite you could only watch the database file itself which would be too noisy i guess. Not sure about postgres, i have not seen dedicated files there, but I did not spend too much time on it. A different thing doable it to outsource this mechanism into another app. We could dispatch an Event on registering those jobs, and a dedicated app can touch a file or run some other action. |
@blizzz thanks for the followup and idea. Another app sounds rather heavy to me, for what I think is something simple. A dedicated app can be created to process the dispatched event later, in the meantime people can use the touched file using inotify. In case of dispatching an event, must the event be removed? Or will that be taken care of automatically? Perhaps for both cases (dispatching an event, and creating a file) a configuration option can be created where the admin can enable the desired mode? |
And there it is the other app: https://github.com/icewind1991/files_inotify but i don't know if it is suitable for the case discussed above. |
@radoeka did you find a solution or practical workaround for this issue? |
@XueSheng-GIT no. I'm still checking every 5 minutes if there is something to update. It would be better with an inotify solution. |
@radoeka I'm using postgresql as database and had a look into trigger functions (https://www.postgresql.org/docs/current/plpgsql-trigger.html). As an initial proof of concept, I added a trigger and trigger function for the First tests were successful and jobs are immediatly executed. |
@radoeka since NC30 there's The following reference (related to Nextcloud AI) can be taken to create a systemd service for this worker. But you need to adapt the required You can do a simple test on console first to see if your workflow scripts are triggered immediately. e.g.:
|
Currently the scripts are run with the next cron job.
This is not usable for some cases, e.g. I try to lock a file with an other app if it's opened or updated.
I don't want to trigger cron any 10 secounds because there are other jobs like generating previews and file scan etc.
Other APP like https://github.com/nextcloud/files_accesscontrol are grip immediatly.
How can I configure this direct behavior with workflow_script?
The text was updated successfully, but these errors were encountered: