github.com/minio/madmin-go/v3@v3.0.51/service-commands-v1.go (about) 1 // 2 // Copyright (c) 2015-2024 MinIO, Inc. 3 // 4 // This file is part of MinIO Object Storage stack 5 // 6 // This program is free software: you can redistribute it and/or modify 7 // it under the terms of the GNU Affero General Public License as 8 // published by the Free Software Foundation, either version 3 of the 9 // License, or (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU Affero General Public License for more details. 15 // 16 // You should have received a copy of the GNU Affero General Public License 17 // along with this program. If not, see <http://www.gnu.org/licenses/>. 18 // 19 20 package madmin 21 22 import ( 23 "context" 24 "net/http" 25 "net/url" 26 ) 27 28 // ServiceRestart - Deprecated: restarts the MinIO cluster 29 func (adm *AdminClient) ServiceRestart(ctx context.Context) error { 30 return adm.serviceCallAction(ctx, ServiceActionRestart) 31 } 32 33 // ServiceStop - Deprecated: stops the MinIO cluster 34 func (adm *AdminClient) ServiceStop(ctx context.Context) error { 35 return adm.serviceCallAction(ctx, ServiceActionStop) 36 } 37 38 // ServiceUnfreeze - Deprecated: un-freezes all incoming S3 API calls on MinIO cluster 39 func (adm *AdminClient) ServiceUnfreeze(ctx context.Context) error { 40 return adm.serviceCallAction(ctx, ServiceActionUnfreeze) 41 } 42 43 // serviceCallAction - call service restart/update/stop API. 44 func (adm *AdminClient) serviceCallAction(ctx context.Context, action ServiceAction) error { 45 queryValues := url.Values{} 46 queryValues.Set("action", string(action)) 47 48 // Request API to Restart server 49 resp, err := adm.executeMethod(ctx, 50 http.MethodPost, requestData{ 51 relPath: adminAPIPrefix + "/service", 52 queryValues: queryValues, 53 }, 54 ) 55 defer closeResponse(resp) 56 if err != nil { 57 return err 58 } 59 60 if resp.StatusCode != http.StatusOK { 61 return httpRespToErrorResponse(resp) 62 } 63 64 return nil 65 }