Skip to content
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

Randomly fails and there are multiple wkhtmltopdf processes #378

Open
rxng opened this issue Dec 13, 2021 · 4 comments
Open

Randomly fails and there are multiple wkhtmltopdf processes #378

rxng opened this issue Dec 13, 2021 · 4 comments

Comments

@rxng
Copy link

rxng commented Dec 13, 2021

Most of the time this works (often for months) without any issues. However, once in a while pdf fails to download and when I check the server , ps aux shows multiple wkhtmltopdf processes.

Once I killall wkhtmltopdf , then the pdf generation works again. Is there a way to overcome this or find out why there are multiple processes?

Could it be two requests to phpwkhtmltopdf at once hangs wkhtmltopdf?

Looking for a way to fix this. Appreciate any help

@mikehaertl
Copy link
Owner

Errors like this are extremely hard to fix. We already refactored the execution of wkhtmltopdf a lot to fix hanging issues (see mikehaertl/php-shellcommand#20). But this only affects Linux systems. So what OS are you on? If you're on Windows I strongly recommend to consider using Linux (e.g. in a Docker container). It's much more stable.

If you don't use Windows I can only recommend to study the linked issue above and the code we used to fix the problem. Then see if you can add some debugging output here and there to find out, where it hangs.

@rxng
Copy link
Author

rxng commented Dec 13, 2021

I am on Debian. It actually works fantastically almost all the time, it really is an awesome library. So it’s unpredictable as to when the issue happens.

The only time I know there’s an issue is when the pdfs don’t generate - this is when I log into the server and run “ps aux”, which shows that the list has multiple wkhtmltopdf processes.

So it seems like whenever there is one wkhtmltopdf process that hangs, from there this affects all others calls to also hang.

@mikehaertl
Copy link
Owner

The main logic is probably best explained in my comment here: mikehaertl/php-shellcommand#20 (comment)

You can try to edit the main loop in mikehaertl/php-shellcommand/src/Command.php and e.g. write something to a log file. Maybe write the current $status to a file after this line:

while ($isRunning) {
    $status = proc_get_status($process);

Also check the lines below where stdin and stdout are read. This part (or the lack of it) caused the processes to hang: The output buffer for stdout was full and wkhtmltopdf was waiting that it was read.

That's basically all help I can provide. You need to be creative how to get more information out of the running process.

@rxng
Copy link
Author

rxng commented Dec 14, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants