@@ -91,11 +91,6 @@ func Run(cliCtx *cli.Context, cliApp *cli.App, configPath string, clickhouseBack
9191 metrics : metrics .NewAPIMetrics (),
9292 stop : make (chan struct {}),
9393 }
94- if cfg .API .CreateIntegrationTables {
95- if err := api .CreateIntegrationTables (); err != nil {
96- log .Error ().Err (err ).Send ()
97- }
98- }
9994 api .metrics .RegisterMetrics ()
10095
10196 log .Info ().Msgf ("Starting API server %s on %s" , api .cliApp .Version , api .config .API .ListenAddr )
@@ -127,14 +122,14 @@ func Run(cliCtx *cli.Context, cliApp *cli.App, configPath string, clickhouseBack
127122 for {
128123 select {
129124 case <- api .restart :
130- if err := api .Restart (); err != nil {
131- log .Error ().Msgf ("Failed to restarting API server: %v" , err )
125+ if restartErr := api .Restart (); restartErr != nil {
126+ log .Error ().Msgf ("Failed to restarting API server: %v" , restartErr )
132127 continue
133128 }
134129 log .Info ().Msgf ("Reloaded by HTTP" )
135130 case <- sighup :
136- if err := api .Restart (); err != nil {
137- log .Error ().Msgf ("Failed to restarting API server: %v" , err )
131+ if restartErr := api .Restart (); restartErr != nil {
132+ log .Error ().Msgf ("Failed to restarting API server: %v" , restartErr )
138133 continue
139134 }
140135 log .Info ().Msg ("Reloaded by SIGHUP" )
@@ -171,6 +166,11 @@ func (api *APIServer) Restart() error {
171166 if err != nil {
172167 return err
173168 }
169+ if api .config .API .CreateIntegrationTables {
170+ if createErr := api .CreateIntegrationTables (); createErr != nil {
171+ log .Error ().Err (createErr ).Send ()
172+ }
173+ }
174174 status .Current .CancelAll ("canceled via API /restart" )
175175 if api .server != nil {
176176 _ = api .server .Close ()
0 commit comments