56 Star 154 Fork 40

青苗 / gmfs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gmfs.go 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
= 提交于 2015-08-13 11:29 . golang 基于 gridFs 的分布式文件服务
package main
import (
"bufio"
"fmt"
"gmfs/core"
"os"
"runtime"
"strconv"
"strings"
)
var helpText = `
gmfs - the notes helper
actions:
gmfs help
gmfs test
gmfs start
`
const config = "conf/config.json"
func main() {
if len(os.Args) == 1 {
help(0)
}
action := os.Args[1]
switch action {
case "help":
help(0)
case "test":
handleNew()
case "start":
core.StartServer(config)
default:
help(0)
}
}
func handleNew() {
ipt := acceptInput("Enter the start server , using CPU cores '0 .. ': ")
if ipt != "" {
cpucores, err := strconv.Atoi(ipt)
if err != nil {
panic(err)
}
fmt.Printf("using %d CPU cores\n", cpucores)
runtime.GOMAXPROCS(cpucores)
core.StartServer(config)
} else {
help(1)
}
}
/**
* 打印帮助信息
*/
func help(exit int) {
fmt.Println(helpText)
os.Exit(exit)
}
/**
* 读取命令行输入
*/
func acceptInput(question string) string {
reader := bufio.NewReader(os.Stdin)
var (
response string
err error
)
for response == "" {
fmt.Print(question)
response, err = reader.ReadString('\n')
if err != nil {
fmt.Println("Oops, what was that?")
os.Exit(1)
}
response = strings.TrimSpace(response)
}
return response
}
Go
1
https://gitee.com/jobob/gmfs.git
git@gitee.com:jobob/gmfs.git
jobob
gmfs
gmfs
master

搜索帮助