How can I get the name of the ColdFusion instance ("cfusion" for example) in ColdFusion 10?
Pre-10 you could do so by using the jrun java object:
<cfobject action="create" type="java" class="jrunx.kernel.JRun" name="jr">
#jr.getServerName()#
But since Jrun has been replaced by Tomcat I need to find a new way of getting the instance name.
I know it can be done using the admin api but that does not work for me because of security issues.
look in the server scope. There is a value at server.coldfusion.rootdir. On CF10 this is the directory of the instance. So for the "cfusion" instance on my Mac for example, this value is /Applications/ColdFusion10/cfusion. You could grab the last directory namd in the path and that is the name of the instance. Not exactly elegant, but might get you what you need.
There is a "runtime" component in the Admin API in CF10. You can get the instance name with this snippet of code:
var runtime = createObject("component", "CFIDE.adminapi.runtime");
instance = runtime.getInstanceName();
This should return the same value as getServerName()
used to in the jrunx.kernel.JRun
component.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With