Get instance name in ColdFusion 10

How can I get a ColdFusion instance name (e.g. cfusion) in ColdFusion 10 ?

Pre-10 you can do this using 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 to get the instance name.

I know that this can be done using the admin api, but this does not work for me due to security issues.

+6
source share
3 answers

look in the server area. The value is server.coldfusion.rootdir. In CF10, this is an instance directory. So, for an instance of "cfusion" on my Mac, for example, this is the value / Applications / ColdFusion 10 / cfusion. You could grab the last namd directory in the path, and that is the instance name. Not quite elegant, but it can get what you need.

+5
source

The CF10 API has a runtime component. You can get the instance name using this code snippet:

 var runtime = createObject("component", "CFIDE.adminapi.runtime"); instance = runtime.getInstanceName(); 

This should return the same value as getServerName() used in the jrunx.kernel.JRun component.

+5
source

This should work:

 <cfset inetAddressObj = createObject("java", "java.net.InetAddress") /> <cfset machineName = inetAddressObj.localhost.getCanonicalHostName() /> 
-5
source

Source: https://habr.com/ru/post/912928/


All Articles