0

here's my problem. I have a server that is started inside Eclipse, so the process is always running until I kill it.

If I want to execute a clean shutdown, I can write "shutdown" directly in the eclipse console and press enter. I need a clean shutdown (and not just a taskkill) because the server is supposed to send a snmp trap before it closes.

What I want to know is, is it possible that the "shutdown" could be written in the console as an input directly from a java method (stopServer())?

This is for tests purpose and it has to be automated. And there is no possibility to write a script that would do that.

Thank you.

3 Answers 3

1

Unless you are not sure that your server can read the input command why even bother doing it with the text command? The text command is only a human readable/interactive form of the functioncall right? Maybe I don't really get what you want, but to me it seems easier to just write a signalhandler that always does the clean shutdown.

If you really wanted to do it, you could probably do it by writing to STDIN though (basicly what the console does).

Sign up to request clarification or add additional context in comments.

Comments

1

Is this a JavaEE server you're setting up and tearing down? If so have you looked into Cargo ? It has lots of functionality to setup, deploy, and tear down containers both in code (in your JUnit beforeClass/afterClass) and/or through a maven plugin as well.

1 Comment

It sure is a really interesting third-party that I didn't know of, but not quite sure if it would be useful in our case. I'll dig a bit into it, thanks.
0

How about the stopServer() method containing all the shutdown logic, and making the shutdown command just another way to call the stopServer() method. That is way easier than sending the command to the console.

1 Comment

For what I know the shutdown logic is way too important (lots of services to stop for example) to be contained in a single method. The problem is also probably the fact that I'm not aware of everything that is happening when the shutdown is executed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.