Thank you for your post.
Can you share the code, that previously worked.
Sure, it was:
oJRun = CreateObject("java", "jrunx.kernel.JRun");
CF10 now says the class jrun.kernel does not exist - is there an equivalent please?
It shouldn't come as a surprise that that JRun-specific code doesn't work on Tomcat ;-)
I dunno the answer to your question, but googling "restart tomcat programmatically" sure comes up with a lot of results. I imagine one or more of those will point you in the right direction.
No surprise that it does not work, I just wondered if there was an equivalent.
As I kinda suggested: wonder-not; just google instead.
It took me about 1min to find what seemed to be a reasonable answer. However I'm not in a position to test it for you, so I shan't post it saying "this should work" as I can't be sure it will. I'm sure if you look at some of those search results though, and test 'em, you'll come up with a solution quick smart. Probably quicker than waiting around here for a useful answer (and I concede mine are mostly not, other than the guidance to use Google is fairly sound).
Already looked on Google and did not find a CF way of doing it. That's what I'm after.
There won't be a "CF way", because CF is an app, and completely unaware of what servlet container it is being run by. However each given servlet container is going to have a completely different API, so you need to find the API-specific way of restarting the servlet container.
The JRun code you cite about isn't a "CF way", it's a Java way, and it's specifically a JRun way of doing it. If you were running your CF instances on Tomcat or Websphere or whatever other servlet containers were supported on <= CF9, then that code would not help you. Bear in mind that even on CF9 and before, JRun was simply the default servlet container (well: it's a J2EE server, but it's the servlet container that it includes that's significant here), and one was not compelled to run CF on JRun. Similarly, one is not compelled to run CF10 on Tomcat, so there simply will not be a "CF way", as the notion doesn't make sense. What you're asking for is akin to asking for a MS-Word way of restarting Windows. There won't be one.
So you need to look at the Tomcat API and see if there's a way of restarting a Tomcat instance. And that is well-trod ground on google.
Another question that is begged here... why are you wanting to restart your Tomcat instance from within your CF app?
When I say CF way, I mean any way using a CFM template. The older Jrun method that I cited is a "CF way", since the Java method is called from within a CFSCRIPT tag. I know the underlying code is Java, but the restart is still achieved by running a CFM template.
Btw, you certainly can restart Windows from within MS-Word. You just write a little VB macro to access the command shell.
In fact, your MS-Word analogy was helpful; I now have a CFM template that restarts the CF application server (or Tomcat instance, if you want to call it that) using a similar method. Not the best nor the most elegant method, but it works quickly and robustly. Meanwhile, I'll wait for <cfrestartmyserver>...
That's two solutions I've found today, I'm on a roll
Please share your solution for the rest of us!
You could start a new thread. That would increase your chances of getting new, fresh suggestions.
WiWildcat, to actually answer the question, I found a few ways, the most crude was a .cfm script something like:
<cfexecute name="C:\Windows\System32\cmd.exe" arguments="/C C:scripts\restartcf.bat" timeout="999"></cfexecute>
where restartcf.bat does a net stop/net start on the ColdFusion service - this is for the Windows platform obviously and uses a batch file.
In our case, we wanted to refresh our instance to get memory usage down. We use some legacy code that has memory leaks and we cannot replace it easily, so If you want to refresh your instance so that it releases (GCs) memory. Our method uses the ColdFusion 10 Administrator API and "toggles" your main database DSN, which is akin to a server refresh, it's a really good solution for us and does not require a server restart. I will private message you the code if that is of interest.
Do you realize you actually asked 2 separate questions in your original post? They are:
How to restart ColdFusion 10 programatically? (the title)
Does anyone have the code (CFSCRIPT/CFML) to restart a CF10 instance?
Which were you aiming for?
We have purchased a full edition of CF for production and use developers copy for test/staging. The development is done at night from one place and testing is performed in a whole 'nother state.
We just need to be able to have the non-technical testers able to restart CF so it released the IP from development and allows testing to go do their thing.
You may perhaps have to make a distinction. What I meant in my last post is that you can stop and restart a ColdFusion instance without having to restart all of ColdFusion.
When you say "restart CF" does that mean restart the CF service? If so, you can use that cfexecute code. We personally cannot use the CFIDE Admin API since it needs a CF version higher than standard. I'm not sure if your full version will support the instance API so you can use it to restart the instance (as opposed to the service) - see http://help.adobe.com/en_US/ColdFusion/10.0/Admin/WSc3ff6d0ea77859461172e0811cbf364104-7fc f.html for details of the API.
I was aiming for either. Either would have helped, but now we have a solution.