@@ -54,6 +54,7 @@ func RunService(c *cli.Context, cliOpts *CLIOpts, streamsMode bool) error {
5454 }
5555
5656 verLogger := logger .With ("benthos_version" , cliOpts .Version )
57+
5758 if mainPath == "" {
5859 verLogger .Info ("Running without a main config file" )
5960 } else if inferredMainPath {
@@ -73,8 +74,9 @@ func RunService(c *cli.Context, cliOpts *CLIOpts, streamsMode bool) error {
7374 if strict && len (lints ) > 0 {
7475 return errors .New (cliOpts .ExecTemplate ("shutting down due to linter errors, to prevent shutdown run {{.ProductName}} with --chilled" ))
7576 }
76-
77- stoppableManager , err := CreateManager (c , cliOpts , logger , streamsMode , conf )
77+ //Success Watcher Count Is Used to for to get count of the config which was updated with the watcher flag.
78+ success_reload_count := 0
79+ stoppableManager , err := CreateManager (c , cliOpts , logger , streamsMode , conf , & success_reload_count )
7880 if err != nil {
7981 return err
8082 }
@@ -90,9 +92,10 @@ func RunService(c *cli.Context, cliOpts *CLIOpts, streamsMode bool) error {
9092 watching := cliOpts .RootFlags .GetWatcher (c )
9193 if streamsMode {
9294 enableStreamsAPI := ! c .Bool ("no-api" )
93- stoppableStream , err = initStreamsMode (cliOpts , strict , watching , enableStreamsAPI , confReader , stoppableManager .Manager ())
95+ stoppableStream , err = initStreamsMode (cliOpts , strict , watching , enableStreamsAPI , confReader , stoppableManager .Manager (), & success_reload_count )
9496 } else {
95- stoppableStream , dataStreamClosedChan , err = initNormalMode (cliOpts , conf , strict , watching , confReader , stoppableManager .Manager ())
97+ logger .Info ("InitMode Get Initiated... strict:%v" , strict )
98+ stoppableStream , dataStreamClosedChan , err = initNormalMode (cliOpts , conf , strict , watching , confReader , stoppableManager .Manager (), & success_reload_count )
9699 }
97100 if err != nil {
98101 return err
@@ -133,6 +136,7 @@ func initStreamsMode(
133136 strict , watching , enableAPI bool ,
134137 confReader * config.Reader ,
135138 mgr * manager.Type ,
139+ success_reload_count * int ,
136140) (RunningStream , error ) {
137141 logger := mgr .Logger ()
138142 streamMgr := strmmgr .New (mgr , strmmgr .OptAPIEnabled (enableAPI ))
@@ -181,7 +185,7 @@ func initStreamsMode(
181185 }
182186
183187 if watching {
184- if err := confReader .BeginFileWatching (mgr , strict ); err != nil {
188+ if err := confReader .BeginFileWatching (mgr , strict , success_reload_count ); err != nil {
185189 return nil , fmt .Errorf ("failed to create stream config watcher: %w" , err )
186190 }
187191 }
@@ -194,6 +198,7 @@ func initNormalMode(
194198 strict , watching bool ,
195199 confReader * config.Reader ,
196200 mgr * manager.Type ,
201+ success_reload_count * int ,
197202) (newStream RunningStream , stoppedChan chan struct {}, err error ) {
198203 logger := mgr .Logger ()
199204
@@ -231,7 +236,7 @@ func initNormalMode(
231236 }
232237
233238 if watching {
234- if err := confReader .BeginFileWatching (mgr , strict ); err != nil {
239+ if err := confReader .BeginFileWatching (mgr , strict , success_reload_count ); err != nil {
235240 return nil , nil , fmt .Errorf ("failed to create config file watcher: %w" , err )
236241 }
237242 }
0 commit comments