Search code examples
angularjstomcathawtio

Is it possible to run OS script from hawt.io plugin (AngularJS)


I've got Tomcat webcontainer (8.0.x) and hawt.io (1.5.10) that runs on top of it.

I would like to write Hawt.io plugin that would restart JVM server, the one that hosts this jvm.

Lets assume I've bash script that I can call to gracefully stop JVM and start it again. Is it possible to call such external OS script from hawt.io plugin? Where do I find any code examples?

ps. I know this will disconnect requesting user from hawt.io web app. Script and jvm would run from the same uid.


Solution

  • I don't think it is possible as a Hawtio plugin is nothing but a front-end AngularJS script which runs on browser. Running an OS script from a browser script is prohibited because otherwise it may open up all the possible security attacks.

    One possible workaround would be to create a custom JMX MBean deployed on your Tomcat server which then runs a system command like Runtime.getRuntime().exec("...") internally, and have a Hawtio plugin to invoke the MBean from browser.