[Looking for Charlie's main web site?]

CF10 Hidden Gem: New method to obtain ColdFusion instance name via CFML code

Note: This blog post is from 2012. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.
One of the many hidden gems in CF10 is that there's a new way to programmatically obtain the current instance name. In CF 6-9, we had to call a method in a JRun class. In CF10, they've added a new method in the Admin API.

The quick answer is that there's a getInstanceName method in the runtime.cfc of the Admin API. And yes, any user can execute this code. They do not need to BE an admin. You can use this in production code. For more, see below.

If that's enough to get you going, have at it. For more info, read on.

[....Continue Reading....]

Comments
Is there still no way (or know way I know of) to select which instance to direct a request to?
# Posted By Tom Jenkins | 7/1/12 8:41 AM
Tom, I assume you're referring to a challenge if you configure a cluster, using the CF Admin Cluster Manager. Is that right?

Either way, I would propose that "select[ing] which instance to direct a request to" is not really a "CF feature". I'd propose it would seem a matter of web server configuration.

First, note first that when you create new instances in the CF Admin Instance Manager (in any release of CF7-10), CF creates that instance initially to run via its internal web server. You can access the instance directly using that, with whatever port it was created to use (starting with 8301 in CF7-9, or 8501 in CF10).

So you should be able to access the instance directly that way. Is that working for you?

But maybe you mean you'd like to configure an external web server (IIS, Apache, etc.) to point to a single instance, while also having put that instance into a CF cluster. Is that the case? That can be harder, since it will show the cluster rather than the instances. But I'm pretty sure that if you run that tool before putting the instances into a cluster, then CF would create a connection to that specific instance, even if it was later put into a cluster.

Of course, you need to come up with some sort of binding for that web site that would access it specifically (whether giving it an alternative port, like 81, or an alternative host header, etc.)

If you may ask any questions in reply, please do clarify if you are using IIS or Apache, and also what you've tried and/or are finding specifically, and what version of CF.

Hope that helps.
Copyright ©2024 Charlie Arehart
Carehart Logo
BlogCFC was created by Raymond Camden. This blog is running version 5.005.
(Want to validate the html in this page?)

Managed Hosting Services provided by
Managed Dedicated Hosting