Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get instance name in ColdFusion 10

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.

like image 764
Jan Brünemann Avatar asked Apr 11 '12 11:04

Jan Brünemann


2 Answers

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.

like image 185
Sean Coyne Avatar answered Oct 23 '22 06:10

Sean Coyne


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.

like image 5
Marcin Avatar answered Oct 23 '22 04:10

Marcin