Reputation: 19
I have a perl script that generated a PDF file. It takes a long time and I get gateway timeout error.
Many websites generate large files then notify user later when ready to download.
My script dies when user browses away.
How can I run the script then notify user when download is ready?
Thank you.
Upvotes: 0
Views: 78
Reputation: 74
Bad answer: Increase the timeout value of the frontend.
Short answer (not really a solution): don't generate PDFs in that script.
Long answer: There are several approaches, but aim to the same: to let the program (ie: your script. lets call it "A") send a response to the client (such as "we are generating your PDF and will be notified") as fast as possible, while another program (lets call it "B") generates the PDF.
B can be a server, can be a script on an while loop polling something, can be a cronjob script executed every minute that checks if some state somewhere changed.
What you do at A largely depends on how you decide to implement B.
Some random ideas:
you get the idea.
Upvotes: 1