1818package org .apache .eventmesh .runtime .boot ;
1919
2020import org .apache .eventmesh .common .config .ConfigService ;
21- import org .apache .eventmesh .common .enums .ComponentType ;
22- import org .apache .eventmesh .runtime .RuntimeInstanceConfig ;
2321import org .apache .eventmesh .runtime .constants .EventMeshConstants ;
2422import org .apache .eventmesh .runtime .util .BannerUtil ;
2523
@@ -38,53 +36,25 @@ public static void main(String[] args) throws Exception {
3836
3937 BannerUtil .generateBanner ();
4038
41- RuntimeInstanceConfig runtimeInstanceConfig = null ;
42- try {
43- runtimeInstanceConfig = ConfigService .getInstance ().buildConfigInstance (RuntimeInstanceConfig .class );
44- } catch (Exception e ) {
45- log .warn ("Failed to load RuntimeInstanceConfig, falling back to legacy EventMeshServer mode" , e );
46- }
47-
48- if (runtimeInstanceConfig != null && runtimeInstanceConfig .getComponentType () != null
49- && runtimeInstanceConfig .getComponentType () != ComponentType .MESH ) {
50- // V2 Runtime (Connector or Function)
51- RuntimeInstance runtimeInstance = new RuntimeInstance (runtimeInstanceConfig );
52- runtimeInstance .init ();
53- runtimeInstance .start ();
54-
55- Runtime .getRuntime ().addShutdownHook (new Thread (() -> {
56- try {
57- log .info ("runtime shutting down hook begin." );
58- long start = System .currentTimeMillis ();
59- runtimeInstance .shutdown ();
60- long end = System .currentTimeMillis ();
61- log .info ("runtime shutdown cost {}ms" , end - start );
62- } catch (Exception e ) {
63- log .error ("exception when shutdown." , e );
64- }
65- }));
66- } else {
67- // Legacy EventMeshServer (Mesh)
68- EventMeshServer server = new EventMeshServer ();
69- server .init ();
70- server .start ();
71- Runtime .getRuntime ().addShutdownHook (new Thread (() -> {
72- try {
73- log .info ("eventMesh shutting down hook begin." );
74- long start = System .currentTimeMillis ();
75- server .shutdown ();
76- long end = System .currentTimeMillis ();
77-
78- log .info ("eventMesh shutdown cost {}ms" , end - start );
79- } catch (Exception e ) {
80- log .error ("exception when shutdown." , e );
81- }
82- }));
83- }
39+ EventMeshServer server = new EventMeshServer ();
40+ server .init ();
41+ server .start ();
42+ Runtime .getRuntime ().addShutdownHook (new Thread (() -> {
43+ try {
44+ log .info ("eventMesh shutting down hook begin." );
45+ long start = System .currentTimeMillis ();
46+ server .shutdown ();
47+ long end = System .currentTimeMillis ();
48+
49+ log .info ("eventMesh shutdown cost {}ms" , end - start );
50+ } catch (Exception e ) {
51+ log .error ("exception when shutdown." , e );
52+ }
53+ }));
8454 } catch (Throwable e ) {
8555 log .error ("EventMesh start fail." , e );
8656 System .exit (-1 );
8757 }
8858
8959 }
90- }
60+ }
0 commit comments