crawler icon indicating copy to clipboard operation
crawler copied to clipboard

Check for `ps` support in ProcessCleanUpHook

Open kpnielsen opened this issue 4 years ago • 4 comments

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.

kpnielsen avatar Jul 13 '21 11:07 kpnielsen

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.

tomasnorre avatar Jul 13 '21 11:07 tomasnorre

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?

kpnielsen avatar Sep 30 '22 11:09 kpnielsen

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?

tomasnorre avatar Oct 03 '22 08:10 tomasnorre