Is it possible to run OS script from hawt.io plugin (AngularJS) - 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.

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.

Related

deployment of queue.xml to new non-default version does not create queues

I am trying to use task queues in GAE Java 8, but somehow it does not seem to deploy correctly via the queue.xml file. I can also not see the task queues in the Cloud Tasks console (which is where I get redirected from the app engine console).
I get an error java.lang.IllegalStateException: The specified queue is unknown : xxxxx when running the app.
The app runs fine locally. I can see the task queues appearing locally in the admin page.
Does this mean that I cannot deploy task queues via queue.xml anymore?
You should be aware that the queue configuration is not a per-version config (or even a per-service one!), it is a global, per-application config. Or per-project if you want - considering that there can only be one GAE application per GCP project.
This single queue configuration is shared by all versions of all services of your application, so:
if/when services/versions need different queue configs all of them need to be merged into a single file for deployment.
pay attention at deployment not to overwrite/negatively impact existing services/versions
While in some cases the queue.xml file might be deployed automatically when you deploy your application code it is not always the case. The official recommended deployment method is using the deployment command dedicated for the queue configuration, which can be performed independently from deploying application/service code. From Deploying the queue configuration file:
To deploy the queue configuration file without otherwise altering the
currently serving version, use the command:
appcfg.sh update_queues <application directory>
replacing <application directory> with the path to your application
main directory.
Pay extra attention if you have:
other non-java standard environment services in your app - they use the queue.yaml queue configuration file, managing the same content in 2 different files/formats can be tricky
other services managing queue via using Cloud Tasks. See Using Queue Management versus queue.yaml.

Flink REST Monitor API

After reading from this documentation: https://ci.apache.org/projects/flink/flink-docs-release-1.2/monitoring/rest_api.html, I know that I can send a POST Request to start a Flink job from a savepoint.
The problem is that: This REST interface is hosted in JobManager, which is only alive if there is a job already running there (I run this locally in a JVM). So this is a contradiction because if I want to start a job, there is no job already running right?
Anyone have any clues?
Flink's monitoring API web server and the web dashboard web server are currently the same and run together at the same port. This means that these instructions for how to start up the web UI from inside an IDE should do the job.

Programmatically restart Node applications on Plesk

We are using Plesk to host our production services.
Basically when I deploy application to Plesk using Git, I need to press Restart application within Node page on Plesk GUI and that works well.
But in some cases I need to do that pragmatically, I need to automatically restart Node service. Does Plesk offer such functionality? Maybe, some kind of API that listens to calls or else within Linux shell itself.
When you click Restart App you'll notice a message state Information: The restart.txt file was touched. Application will be restarted after the first request.
You can emulate this action after the deploy by checking Enable additional deploy actions in the git repository options, and touching the same file here (I also run npm install too). Screenshot attached.
Since there was no answer for a while, this is my old workaround that I used for PM2 scripts force reset:
If it's a webserver application, e.g. Express.js, add protected route that can be accessed only within your privatae network (for security reasons) which basically kills main process via process.exit(0) and your webserver will get reseted automatically by PM2 or whichever service you use for it. However, I wouldn't recommend this method for anything above staging.
I have this issue too, and Plesk support don't have an answer for me either.
According to the Plesk blog here: "Moreover, if your app is running in the “development” mode, you don’t need to restart the app every time you modify the contents of a file."
I'm very new to Node so I don't fully understand the implications but I guess if you run the app in development mode, then you won't need to manually restart the Node Application.
The only way I have found that consistently works on Plesk is this command:
touch tmp/restart.txt
Even in development mode, Node does not seem to automatically restart.
What's worse is that it takes about 5-6 seconds before Node finishes restarting, using the touch method.
My takeaway is that a Plesk server is the wrong place to do Node development or testing.

Embedding jetty for Apache camel

I have a file transfer routing developed in Apache camel. I want to embed Jetty server into this project so that i can keep the service running without deploying it to another server. It will be really helpful if someone can put some code.
Thank You.
You should use Camel's Jetty component and declare a consumer, which will automatically bring up an embedded Jetty:
from("jetty:http://localhost:{{port}}/myapp/myservice")
.process(new MyProcessor());
You have 2 options, they are quite popular:
Use maven camel:run plugin, you have to just enable this in your pom file and run the command. (I am not too sure whether they use Jetty internally, but it works)
Spring boot, Its quite easy to create a project nowadays, using the web portal.
There is one more maven plugin as well for Jetty , which is mvn jetty:run

programmatically get server load information from Apache ServiceMix using JMX

Is it possible to get the server load information of a webserver deployed on a ServiceMix / Fuse ESB.
I dont want to use Jconsole but get the information by running a java file and writing the values into text file.
Could someone point me to some code that I can run on my machine?
Cheers,
Kunal
You can also intall jolokia i ServiceMix which exposes a REST interface over JMX. This makes it much easier for non Java developers and programming languages to access the metrics. It's just a HTTP call to get the data.
http://www.jolokia.org/
We use this library for the http://hawt.io management console so we can get the data easily from a moderne HTML5 web console.
I won't write the code you ask for, but..
Everything in JConsole is accessed through JMX. And everything in JMX is accessible via code as well (basic tutorial here).
So just locate the value/values you are intressted in using JConsole, then just extract them using the JMX api in code.

Resources