@@ -215,7 +215,7 @@ func (s *stat) run() (err error) {
215
215
s .log .Errorf ("error creating listener at addr %s: %v" , addr , err )
216
216
return
217
217
}
218
- s .log .Infof ("started status http server at %s" , addr )
218
+ s .log .Infof ("Started status http server at %s" , addr )
219
219
220
220
s .lastRowEvent = time .Now ()
221
221
s .startedAt = time .Now ()
@@ -232,9 +232,10 @@ func (s *stat) run() (err error) {
232
232
mux .Handle ("/debug/pprof/symbol" , http .HandlerFunc (pprof .Symbol ))
233
233
mux .Handle ("/debug/pprof/trace" , http .HandlerFunc (pprof .Trace ))
234
234
235
- mux .Handle ("/rebuild" , handleRebuildRedir ())
236
- mux .Handle ("/rebuild/sync" , handleRebuild (s .r , true ))
237
- mux .Handle ("/rebuild/async" , handleRebuild (s .r , false ))
235
+ // mux.Handle("/rebuild", handleRebuildRedir())
236
+ // mux.Handle("/rebuild/sync", handleRebuild(s.r, true))
237
+ // mux.Handle("/rebuild/async", handleRebuild(s.r, false))
238
+
238
239
mux .Handle ("/maint" , handleMaint (s .r ))
239
240
mux .Handle ("/wait" , handleWaitForGTID (s .r ))
240
241
@@ -334,54 +335,63 @@ func handleRebuild(r *River, sync bool) http.HandlerFunc {
334
335
func handleMaint (r * River ) http.HandlerFunc {
335
336
return http .HandlerFunc (func (w http.ResponseWriter , req * http.Request ) {
336
337
w .Header ().Set ("Content-Type" , "text/plain; charset=utf-8" )
338
+
337
339
if req .Method != http .MethodPost {
338
340
w .WriteHeader (http .StatusMethodNotAllowed )
339
341
w .Write ([]byte ("unexpected method\n " ))
340
342
return
341
343
}
344
+
342
345
index := req .URL .Query ().Get ("index" )
343
346
if index == "" {
344
347
w .WriteHeader (http .StatusBadRequest )
345
348
w .Write ([]byte ("index not specified\n " ))
346
349
return
347
350
}
351
+
348
352
dataSource , exists := r .c .DataSource [index ]
349
353
if ! exists {
350
354
w .WriteHeader (http .StatusNotFound )
351
355
w .Write ([]byte (fmt .Sprintf ("index %s not found\n " , index )))
352
356
return
353
357
}
358
+
354
359
err := r .sphinxService .CheckIndexForOptimize (index , dataSource .Parts )
355
360
if err != nil {
356
361
w .WriteHeader (http .StatusInternalServerError )
357
362
w .Write ([]byte (errors .ErrorStack (err ) + "\n " ))
358
363
return
359
364
}
365
+
360
366
w .WriteHeader (http .StatusNoContent )
361
367
})
362
368
}
363
369
364
370
func handleWaitForGTID (r * River ) http.HandlerFunc {
365
371
return http .HandlerFunc (func (w http.ResponseWriter , req * http.Request ) {
366
372
w .Header ().Set ("Content-Type" , "text/plain; charset=utf-8" )
373
+
367
374
if req .Method != http .MethodPost {
368
375
w .WriteHeader (http .StatusMethodNotAllowed )
369
376
w .Write ([]byte ("unexpected method\n " ))
370
377
return
371
378
}
379
+
372
380
req .ParseForm ()
373
381
gtidString := req .PostForm .Get ("gtid" )
374
382
if gtidString == "" {
375
383
w .WriteHeader (http .StatusBadRequest )
376
384
w .Write ([]byte ("gtid not specified\n " ))
377
385
return
378
386
}
387
+
379
388
gtid , err := mysql .ParseGTIDSet (r .c .Flavor , gtidString )
380
389
if err != nil {
381
390
w .WriteHeader (http .StatusUnprocessableEntity )
382
391
w .Write ([]byte ("invalid gtid specified\n " ))
383
392
return
384
393
}
394
+
385
395
timeoutString := req .PostForm .Get ("timeout" )
386
396
var timerC <- chan time.Time
387
397
if timeoutString != "" {
0 commit comments