Is there a plugin monitoring IDEAs console for some special text and able to execute some tool?

Answered

Hi everyone,

I have a Spring Boot-app and would like to do something after I manually stopped that. After stopping, the IDEA console prints the following text, which in theory is somewhat secure to recognize. The important thing is that this message really comes from IDEA and is printed in the console only, it's not part of some logging, so file-based monitors or watchers won't be of too much help.

Process finished with exit code …

Is there any way to monitor console output for that text and do something? “Something” means executing an external tool, a shell command or something.

Thanks!

0
4 comments

Hi Thorsten,

What kind of tool or command do you have in mind?

Process finished with exit code … is a standard Java message. 0 usually means the process terminated normally with no error condition. Other codes generally indicate a specific error condition, but the meaning varies depending on the process. 

In Java, your application can set a return code using System.exit(). If JVM encounters a low-level error or uncaught exception, it's also possible it could return a non-zero value instead of the value explicitly returned by your application. You can try handling such errors in code.

You can also enable the following option in the run configuration settings for Java apps to save console output to a file so that you can parse that file with other tools post execution:

If you want a particular script to run after the app execution is finished, you can set up a Shell Script configuration and run it in sequence after the Java App configuration.

You can also look into Compound Run Configurations and External Tools.

0

You can try handling such errors in code.

There's no code from me, I'm starting a Spring Boot-app using a run-config. I stop the Spring Boot-app using the stop-button in the UI. After the app was stopped, I want to execute “taskkill […]” somehow and that's currently not possible. I hoped there's some way to monitor the console output or something, because of the somewhat individual error message.

I know about the external tools etc., but those don't help me. I can only start those before the run-config and don't want to change the run-config too deal with things manually too much as well. That run-config is good as it is. The only missing part is a trigger for when I stopped the app.

Thought about saving things into a file and use File Watchers as well, but hoped there would be an easier solution. As IntelliJ tracks the result of the started Java process anyway already, best would be to be able to attach to that event.

0
No other way at the moment I'm afraid.
You are welcome to vote up https://youtrack.jetbrains.com/issue/IDEA-124987 and linked feature requests.
0

Thanks, did already, just hoped there might be a different workaround for the time being. :-)

0

Please sign in to leave a comment.