Jump to content

Background proces (shell_exec)


spoetnik
 Share

Recommended Posts

A "Batch" function, or "background" function would be nice given the following use-case.

Process the files from an upload field, and index the processed values in your indexing server. There is no need for the webuser to waith for this processing, it could perfectly happen in the background using 

shell_exec
Link to comment
Share on other sites

It would be possible to add such a function with a custom module. It hooks after the Upload and then hands over the files to the shell. Disregarding any security concerns from the shell_exec which you should be avoided.

You could try LazyCron (part of ProcessWire) for longer tasks in the background or use normal Cronjob to perform those tasks. There is cron.pw which is super cool to run functions regulary.

Another idea, avoiding the shell_exec: A module that writes the files into a queue (database or file or directory) and then a Cronjob runs your programm that will search for jobs in this queue.

EDIT: As we're here in the Wishlist section of the forum: I disagree to put something like this into the core of ProcessWire. Beside security concerns, this can be easily solved with the methods described above.

  • Like 1
Link to comment
Share on other sites

Going to agree with Philipp there. Especially in the light of some of the "high profile" vulnerabilities uncovered lately, I believe that security is one of the true strengths of ProcessWire. While exec(), shell_exec(), system(), passthru(), etc. are powerful and very useful in controlled environments, they also introduce a whole new set of risks, and IMHO are rarely something you'd want to include in the core of an open source platform.

That being said, there's nothing stopping you from using them in your own modules :)

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...