Note that there are some explanatory texts on larger screens.

plurals
  1. POSet a timeout for loading a file from an EBS share
    primarykey
    data
    text
    <p>So I have an interesting situation and I'm not sure how to get around it.</p> <p>We have a process that takes an aggregate look at our sales data and then builds a graph via Google Chart. To keep from hammering the database (or Google for that matter) it only runs this every 30 minutes. It looks at the previous file to determine if it's hit the 30 minute threshold and, if so, it builds the new file. We have two servers behind a load balancer. So both servers have to have access to the same location to store this file. We did this using an EBS share, mounted via NFS (our entire setup is in AWS). This process works just fine.</p> <p>The problem is sometimes the EBS share is slow or disconnected. This causes a ripple effect then, throughout our internal tools waiting on this one file to process (unless you turn the notice off). I've read a few threads (like <a href="https://stackoverflow.com/questions/4165296/check-if-nfs-share-is-up-in-php">this one</a>) that talk about <a href="http://www.php.net/manual/en/function.stream-set-timeout.php" rel="nofollow noreferrer">stream_set_timeout</a> but it's not clear how you would use that with loading a file (it's not exactly a stream) and I've been unable to find any examples.</p> <p>Here's a snippet to give you an idea what the PHP file is doing</p> <pre><code>$file = '/ebs/path/to/image.png'; $newfile=false; if(!is_file($file)) $newfile=true; elseif(filemtime($file)+1800 &lt; time()) { $newfile=true; unlink($file); } if(!$newfile){ $i=imagecreatefrompng($file); header('Content-Type: image/png'); header('Expires: ' . gmdate('D, d M Y H:i:s', filemtime($file) + $timeout) . ' GMT'); imagepng($i); imagedestroy($i); exit; } else { // Build and output a new file here } </code></pre> <p>How could I create a timeout for this script?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload