omeka / Omeka

A flexible web publishing platform for the display of library, museum and scholarly collections, archives and exhibitions.
http://omeka.org
GNU General Public License v3.0
484 stars 195 forks source link

Background long running processes with Windows #813

Open ghost opened 7 years ago

ghost commented 7 years ago

Server software

Windows Server 2012 R2 Apache 2.4: web server runs as a service started by a non-privileged user. The user can log on as a service and log on as a batch job. PHP 5.6 Omeka 2.4.1

Problem

Neither CSVImport Plugin nor BulkEditor Plugin can send long running processes to background. We don't want to change to synchronous (foreground) running. After take a look to error logs and debug, I've found out a problem in this file: Omeka/application/libraries/Omeka/Job/Process/Dispatcher.php line 157: exec("$command > /dev/null 2>&1 &");

This line sends the process to background (linux style). In our server, it fails and doesn't execute the command.

My temporary fix

If I make this change it works: exec("$command > NUL"); In fact, Windows execute the command in foreground with the apache user account, so it starts cmd.exe and closes when the process finishes. To run in background under Windows, maybe: exec("START /B $command > NUL");

luku commented 6 years ago

I was using this pclose(popen("start /B {$command}", 'r')); in one project.

I was briefly checking and there are more Linux specific cmds, like file, which, kill, ... So Windows port would require rewriting all these as well.