Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce an exit request API with wait-for-exit method #6498

Closed
dmlloyd opened this issue Jan 10, 2020 · 4 comments
Closed

Introduce an exit request API with wait-for-exit method #6498

dmlloyd opened this issue Jan 10, 2020 · 4 comments
Labels
kind/enhancement New feature or request
Milestone

Comments

@dmlloyd
Copy link
Member

dmlloyd commented Jan 10, 2020

Description
Introduce an exit request API with wait-for-exit method. Methods should be defined as follows:

  • A method to request that the application exit with a given exit code (non blocking) (e.g. requestExit(int); code must be between 0 and 255 (inclusive))
  • A method to request that the application exit with no code (0 is implied) (non blocking) (e.g. requestExit())
  • A method to wait for an exit request; this method returns the requested exit code (blocking) (e.g. awaitExit())
@gastaldi
Copy link
Contributor

Dumb question, but after the application exits, what is a valid use case for awaitExit()?

@dmlloyd
Copy link
Member Author

dmlloyd commented Jan 14, 2020

The awaitExit method would be used to wait for someone to call requestExit. Once exit is requested, awaitExit returns the requested exit code.

@ToWipf
Copy link

ToWipf commented Apr 30, 2020

My way to stop the application:

private boolean bShutdown = false;

@Override
public int run(String... args) throws Exception {
	LOGGER.info("start");
	while (true) {
		Thread.sleep(1000);
		if (bShutdown) {
			LOGGER.info("stop");
			return 0;
		}
	}
}

public void stopApp() {
	this.bShutdown = true;
}

@stuartwdouglas
Copy link
Member

This is present in Quarkus.waitForExit and Quarkus.asyncExit

@stuartwdouglas stuartwdouglas added this to the 1.4.0.Final milestone May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants