I would like to monitor the availability of a data driven page that has been known not to load due to being unable to create the temporary files required by the image resize function. It's happened a handful of times since launch in April/May and my host restarts the server to solve the problem - not sure that's the best way but that appears to be what they do. I'm uncertain as to whether uptime monitoring would inform me of failure to load the page in question as I'm not sure what exactly these types of services are checking. The availability of the site as a whole doesn't seem to be a problem, but the site's main purpose is to promote the business and advertise properties on its properties page and the availability of this page is, therefore, absolutely crucial to the likely longterm success of the site.
I know this is probably a very basic question, but if someone can point me in the right direction, I would be most grateful.
ok, then it sounds like there is a problem with the image resize function code or maybe something wrong with the image file that is being resized.
Can you post the code for your image resize function and the code calling this function?
The main property image file exists. It is resized just for the property list page. 90% of the time it works then it fails for no apparent reason. Even with no new files. Support have offered to look into it for me & I think I need to put some proper error handling in place. It's just the page that fails, by the way, not the whole site
It's not clear to me exactly what the problem is.
It sounds like that if an image file doesn't exist then your image resize function freezes something up to the point where your server needs to be restarted.
It looks like your code just needs to check if the image file exists before doing anything.
The first block of resizing code is for a 'feature' area:
<!--- Display the Featured Property --->
<!--- Property Name, Short Description, Price and Image --->
<!--- Resizing the image allows me to keep a full size image in the database for use with the schedule --->
<table title="Featured Property">
<tbody><cfimage source="properties/#GetProperty.propertyname#/images/#GetProperty.imagefilename#" action="resize" width="60%" height="60%" destination="properties/#GetProperty.propertyname#/images/#GetProperty.imagefilename#feature_sm.jpg" overwrite="true">
It's called by this code:
<td title="Featured Property Image - Click for Full Details">
<img src="properties/#GetProperty.propertyname#/images/#GetProperty.imagefilename#_sm.jpg" alt="Image of property called #GetProperty.propertyname#" />
Then, this resize code is used in the main body of the page:
<table title="All Properties">
<tbody><cfimage source="properties/#show_properties.propertyname#/images/#show_properties.imagefilename#" action="resize" width="60%"
height="60%" destination="properties/#show_properties.propertyname#/images/#show_properties.imagefilename#_sm.jpg" overwrite="true">
and it is called by this code:
<td title="Property Image for #show_properties.propertyname# - Click for Full Details">
<img src="properties/#show_properties.propertyname#/images/#show_properties.imagefilename#sm.jpg" alt="Image of property called #showproperties.propertyname#" />
Thanks for answering my post. Hopefully you might spot something I haven't thought of. Either way, I still think I need some exception handling code in there to prevent the whole page from falling over because the file cannot be created.
I am not sure what your site does, but can you maybe resize via cron job at sometime in the early morning, then serve it up?
So you/a user uploads file: pic-0001.jpg. at 3am, it reduces the image to your pixel size then saves it as pic-001_sm.jpg.
This is what we did for a site I worked on years ago. (i was the front end guy, and it was in asp.net not CF so I cannot directly help)
Thanks for your advice. I'll certainly consider it. I'd like to try to stick with the ColdFusion resize code but it needs NOT to put the page down with a hideous error message! I should be able to prevent that happening if the file has already been created before - i.e. if a temporary file already exists, I probably ought to be simply displaying that rather than getting it to recreate it each time.
To answer your question about what the site does. It's a website for a Solicitors/Estate Agents and most of the pages clients see are static but the properties.cfm page is a listing (like a product catalogue) of all the properties my clients have for sale or let at the moment. There is a feature box at the top of the page which displays the different properties in turn - a different one each time the page is reloaded rather than a slideshow - and then the rest of the page just has the rest of the properties listed in the same way but outwith the feature box. The basic listing is small image + text and this takes the image the client has uploaded as the main property image and resizes it to a smaller size for display on the properties listing page. This means my clients only have to upload the images they want and resize them once before they upload them - it's to simplify things for my clients. As they may add a property through the web forms behind the login during the day, it probably wouldn't work to resize them once at the beginning of the day, but as I said, all suggestions are welcome and I'll consider it if I can't sort out the image resize function that's there.
I should also say that the service I have monitoring the site will, in fact, alert me when the page gives this error page by the looks of things as it alerted me yesterday when a 503 error was given and then a few minutes later when the status changed back to 200 - OK. It was useful to know that the page was down for 5 minutes and that this is obviously going to be picked up. Equally, the monitoring service said I could specify the page itself in the URL and I would then have that page specifically monitored, which might be quite useful.