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

core: minor formatting changes for bootstrap #1102

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions zuul-sample/src/main/java/com/netflix/zuul/sample/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import com.google.inject.Injector;
import com.netflix.zuul.netty.server.BaseServerStartup;
import com.netflix.zuul.netty.server.Server;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Bootstrap
Expand All @@ -29,13 +32,15 @@
*/
public class Bootstrap {

private static final Logger logger = LoggerFactory.getLogger(Bootstrap.class);

public static void main(String[] args) {
new Bootstrap().start();
}

public void start() {
System.out.println("Zuul Sample: starting up.");
long startTime = System.currentTimeMillis();
long startNanos = System.nanoTime();
logger.info("Zuul Sample: starting up.");
int exitCode = 0;

Server server = null;
Expand All @@ -45,13 +50,13 @@ public void start() {
BaseServerStartup serverStartup = injector.getInstance(BaseServerStartup.class);
server = serverStartup.server();

long startupDuration = System.currentTimeMillis() - startTime;
System.out.println("Zuul Sample: finished startup. Duration = " + startupDuration + " ms");

server.start();
long startupDuration = System.nanoTime() - startNanos;
logger.info(
"Zuul Sample: finished startup. Duration = {}ms", TimeUnit.NANOSECONDS.toMillis(startupDuration));
server.awaitTermination();
}
catch (Throwable t) {
} catch (Throwable t) {
// Don't use logger here, as we may be shutting down the JVM and the logs won't be printed.
t.printStackTrace();
System.err.println("###############");
System.err.println("Zuul Sample: initialization failed. Forcing shutdown now.");
Expand All @@ -60,7 +65,9 @@ public void start() {
}
finally {
// server shutdown
if (server != null) server.stop();
if (server != null) {
server.stop();
}

System.exit(exitCode);
}
Expand Down