2017-05-26 10:09:07 +00:00
|
|
|
// +build node
|
|
|
|
// 任务节点
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ouqiang/gocron/modules/rpc/server"
|
2017-08-05 17:00:41 +00:00
|
|
|
"flag"
|
|
|
|
"runtime"
|
|
|
|
"os"
|
|
|
|
"fmt"
|
2017-09-06 03:27:54 +00:00
|
|
|
"strings"
|
2017-05-26 10:09:07 +00:00
|
|
|
)
|
|
|
|
|
2017-08-05 17:00:41 +00:00
|
|
|
const AppVersion = "1.1"
|
|
|
|
|
2017-05-26 10:09:07 +00:00
|
|
|
func main() {
|
2017-08-05 17:00:41 +00:00
|
|
|
var serverAddr string
|
|
|
|
var allowRoot bool
|
|
|
|
var version bool
|
2017-09-06 03:27:54 +00:00
|
|
|
var keyFile string
|
|
|
|
var certFile string
|
2017-08-05 17:00:41 +00:00
|
|
|
flag.BoolVar(&allowRoot, "allow-root", false, "./gocron-node -allow-root")
|
|
|
|
flag.StringVar(&serverAddr, "s", "0.0.0.0:5921", "./gocron-node -s ip:port")
|
2017-09-06 03:27:54 +00:00
|
|
|
flag.StringVar(&certFile, "cert-file", "", "./gocron-node -cert-file path")
|
|
|
|
flag.StringVar(&keyFile, "key-file", "", "./gocron-node -key-file path")
|
2017-08-05 17:00:41 +00:00
|
|
|
flag.BoolVar(&version, "v", false, "./gocron-node -v")
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
if version {
|
|
|
|
fmt.Println(AppVersion)
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
|
2017-09-06 03:27:54 +00:00
|
|
|
certFile = strings.TrimSpace(certFile)
|
|
|
|
keyFile = strings.TrimSpace(keyFile)
|
|
|
|
|
|
|
|
if certFile != "" && keyFile == "" {
|
|
|
|
fmt.Println("missing argument key-file")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if keyFile != "" && certFile == "" {
|
|
|
|
fmt.Println("missing argument cert-file")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-08-05 17:00:41 +00:00
|
|
|
if runtime.GOOS != "windows" && os.Getuid() == 0 && !allowRoot {
|
|
|
|
fmt.Println("Do not run gocron-node as root user")
|
|
|
|
os.Exit(1)
|
2017-05-26 13:59:01 +00:00
|
|
|
}
|
2017-08-05 17:00:41 +00:00
|
|
|
|
|
|
|
|
2017-09-06 03:27:54 +00:00
|
|
|
|
|
|
|
server.Start(serverAddr, certFile, keyFile)
|
2017-05-26 10:09:07 +00:00
|
|
|
}
|