Skip to content

Commit

Permalink
core: minor formatting changes for bootstrap (Netflix#1102)
Browse files Browse the repository at this point in the history
  • Loading branch information
carl-mastrangelo authored and argha-c committed Mar 18, 2022
1 parent ec62fc2 commit 30a57e7
Showing 1 changed file with 15 additions and 8 deletions.
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

0 comments on commit 30a57e7

Please sign in to comment.