@@ -411,11 +411,13 @@ int flb_engine_start(struct flb_config *config)
411411 return -1 ;
412412 }
413413
414- /* Start the Storage engine */
415- ret = flb_storage_create ( config );
416- if (ret == -1 ) {
414+ /* Create the event loop and set it in the global configuration */
415+ evl = mk_event_loop_create ( 256 );
416+ if (! evl ) {
417417 return -1 ;
418418 }
419+ config -> evl = evl ;
420+
419421
420422 flb_info ("[engine] started (pid=%i)" , getpid ());
421423
@@ -425,13 +427,6 @@ int flb_engine_start(struct flb_config *config)
425427 flb_debug ("[engine] coroutine stack size: %u bytes (%s)" ,
426428 config -> coro_stack_size , tmp );
427429
428- /* Create the event loop and set it in the global configuration */
429- evl = mk_event_loop_create (256 );
430- if (!evl ) {
431- return -1 ;
432- }
433- config -> evl = evl ;
434-
435430 /*
436431 * Create a communication channel: this routine creates a channel to
437432 * signal the Engine event loop. It's useful to stop the event loop
@@ -446,6 +441,12 @@ int flb_engine_start(struct flb_config *config)
446441 return -1 ;
447442 }
448443
444+ /* Start the Storage engine */
445+ ret = flb_storage_create (config );
446+ if (ret == -1 ) {
447+ return -1 ;
448+ }
449+
449450 /* Initialize input plugins */
450451 ret = flb_input_init_all (config );
451452 if (ret == -1 ) {
@@ -491,6 +492,12 @@ int flb_engine_start(struct flb_config *config)
491492 return -1 ;
492493 }
493494
495+ #ifdef FLB_HAVE_METRICS
496+ if (config -> storage_metrics == FLB_TRUE ) {
497+ config -> storage_metrics_ctx = flb_storage_metrics_create (config );
498+ }
499+ #endif
500+
494501 /* Initialize collectors */
495502 flb_input_collectors_start (config );
496503
@@ -647,7 +654,6 @@ int flb_engine_shutdown(struct flb_config *config)
647654 flb_input_exit_all (config );
648655 flb_output_exit (config );
649656
650-
651657 /* Destroy the storage context */
652658 flb_storage_destroy (config );
653659
0 commit comments