1 /*
 2  * Copyright 2017-2024 original authors
 3  *
 4  * Licensed under the Apache License, Version 2.0 (the "License");
 5  * you may not use this file except in compliance with the License.
 6  * You may obtain a copy of the License at
 7  *
 8  * https://www.apache.org/licenses/LICENSE-2.0
 9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package example.micronaut;
17 
18 import java.lang.management.ManagementFactory;
19 import java.lang.management.RuntimeMXBean;
20 
21 import io.micronaut.runtime.Micronaut;
22 
23 public class Application {
24 
25     public static void main(String[] args) {
26  	long mainStart = System.currentTimeMillis();
27  	RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
28  	// This includes all the time spent inside the JVM before main() is reached
29  	// (since os::Posix::init is called and initial_time_count is initialized).
30  	long vmStart = runtimeMXBean.getStartTime();
31  	long maxBeanOverHead = System.currentTimeMillis() - mainStart;
32 
33         Micronaut.run(Application.class, args);
34 
35         if (Boolean.getBoolean("autoQuit")) {
36             long end = System.currentTimeMillis();
37             System.out.println("#### Booted and returned in " + (end - vmStart - maxBeanOverHead) + "ms");
38             System.out.println("#### (debug) mainStart = " + mainStart);
39             System.out.println("#### (debug) vmStart = " + vmStart);
40             System.out.println("#### (debug) before main (mainStart - vmStart) = " + (mainStart - vmStart));
41             System.out.println("#### (debug) maxBeanOverHead = " + maxBeanOverHead);
42             System.out.println("#### (debug) end = " + end);
43 
44             System.out.println("Done .. Exiting");
45             System.exit(0);
46         }
47     }
48 }