crawler
crawler copied to clipboard
Check for `ps` support in ProcessCleanUpHook
Feature Request
Is your feature request related to a problem? Please describe.
On some shared hosting environments (e.g. Mittwald which is very popular in Germany) the ps command is not available due to security considerations. The ProcessCleanUpHook uses ps to find orphaned queue processes if the option cleanup.cleanUpOldQueueEntries is set to true.
Describe the solution you would like
Ideally the hook would check whether ps is can be executed and try to execute an alternative, if it is not. I don't know of any such alternatives, though.
Describe alternatives you've considered
Alternatively, the hook could use try {} catch() {} and merely print out a warning.
Hi @kpnielsen
Thanks for your input. I wasn't aware of that, and will try to come up with another solution on how to detect this.
Just got back to this because a colleague of mine stumbled across this very same problem, again.
It might be enough to wrap the exec('ps aux ...') call in the hook with an if-statement like so
// …
if (`which ps`) {
exec('…');
} else {
trigger_error("Cannot locate ps command", E_USER_WARNING);
}
// …
This would at least prevent the scheduler from failing altogether. Is there anything that speaks against it?
This would at least stop the scheduler from failing, but would still not make the crawler working on systems without ps.
So we can add this for now, and still consider better options. Would you mind creating the PR?