mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
server: Add more elaborate startup messages. (#2731)
These messages based on our prep stage during XL and prints more informative message regarding drive information. This change also does a much needed refactoring.
This commit is contained in:
@@ -18,9 +18,11 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/minio/mc/pkg/console"
|
||||
)
|
||||
|
||||
@@ -44,6 +46,7 @@ func printStartupMessage(endPoints []string) {
|
||||
printServerCommonMsg(endPoints)
|
||||
printCLIAccessMsg(endPoints[0])
|
||||
printObjectAPIMsg()
|
||||
printStorageInfo()
|
||||
}
|
||||
|
||||
// Prints common server startup message. Prints credential, region and browser access.
|
||||
@@ -58,7 +61,11 @@ func printServerCommonMsg(endPoints []string) {
|
||||
// Colorize the message and print.
|
||||
console.Println(colorBlue("\nEndpoint: ") + colorBold(fmt.Sprintf(getFormatStr(len(endPointStr), 1), endPointStr)))
|
||||
console.Println(colorBlue("AccessKey: ") + colorBold(fmt.Sprintf("%s ", cred.AccessKeyID)))
|
||||
console.Println(colorBlue("SecretKey: ") + colorBold(fmt.Sprintf("%s ", cred.SecretAccessKey)))
|
||||
secretKey := cred.SecretAccessKey
|
||||
if os.Getenv("MINIO_SECURE_CONSOLE") == "0" {
|
||||
secretKey = "*REDACTED*"
|
||||
}
|
||||
console.Println(colorBlue("SecretKey: ") + colorBold(fmt.Sprintf("%s ", secretKey)))
|
||||
console.Println(colorBlue("Region: ") + colorBold(fmt.Sprintf(getFormatStr(len(region), 3), region)))
|
||||
printEventNotifiers()
|
||||
|
||||
@@ -90,11 +97,15 @@ func printCLIAccessMsg(endPoint string) {
|
||||
|
||||
// Configure 'mc', following block prints platform specific information for minio client.
|
||||
console.Println(colorBlue("\nCommand-line Access: ") + mcQuickStartGuide)
|
||||
secretKey := cred.SecretAccessKey
|
||||
if os.Getenv("MINIO_SECURE_CONSOLE") == "0" {
|
||||
secretKey = "*REDACTED*"
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
mcMessage := fmt.Sprintf("$ mc.exe config host add myminio %s %s %s", endPoint, cred.AccessKeyID, cred.SecretAccessKey)
|
||||
mcMessage := fmt.Sprintf("$ mc.exe config host add myminio %s %s %s", endPoint, cred.AccessKeyID, secretKey)
|
||||
console.Println(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage))
|
||||
} else {
|
||||
mcMessage := fmt.Sprintf("$ mc config host add myminio %s %s %s", endPoint, cred.AccessKeyID, cred.SecretAccessKey)
|
||||
mcMessage := fmt.Sprintf("$ mc config host add myminio %s %s %s", endPoint, cred.AccessKeyID, secretKey)
|
||||
console.Println(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage))
|
||||
}
|
||||
}
|
||||
@@ -107,3 +118,24 @@ func printObjectAPIMsg() {
|
||||
console.Println(colorBlue(" Python: ") + fmt.Sprintf(getFormatStr(len(pyQuickStartGuide), 4), pyQuickStartGuide))
|
||||
console.Println(colorBlue(" JavaScript: ") + jsQuickStartGuide)
|
||||
}
|
||||
|
||||
// Get formatted disk/storage info message.
|
||||
func getStorageInfoMsg() string {
|
||||
storageInfo := newObjectLayerFn().StorageInfo()
|
||||
msg := fmt.Sprintf("%s %s Free", colorBlue("Drive Capacity:"), humanize.IBytes(uint64(storageInfo.Free)))
|
||||
diskInfo := fmt.Sprintf(" %d Online, %d Offline. We can withstand [%d] more drive failure(s).",
|
||||
storageInfo.Backend.OnlineDisks,
|
||||
storageInfo.Backend.OfflineDisks,
|
||||
storageInfo.Backend.Quorum,
|
||||
)
|
||||
if storageInfo.Backend.Type == XL {
|
||||
msg += colorBlue("\nStatus:") + fmt.Sprintf(getFormatStr(len(diskInfo), 8), diskInfo)
|
||||
}
|
||||
return msg
|
||||
}
|
||||
|
||||
// Prints startup message of storage capacity and erasure information.
|
||||
func printStorageInfo() {
|
||||
console.Println()
|
||||
console.Println(getStorageInfoMsg())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user