|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"flag"
|
|
|
|
|
"fmt"
|
|
|
|
|
"log"
|
|
|
|
|
"os"
|
|
|
|
@ -36,11 +37,43 @@ import (
|
|
|
|
|
_ "github.com/didi/nightingale/v4/src/modules/server/plugins/api"
|
|
|
|
|
|
|
|
|
|
_ "github.com/go-sql-driver/mysql"
|
|
|
|
|
"github.com/toolkits/file"
|
|
|
|
|
pcache "github.com/toolkits/pkg/cache"
|
|
|
|
|
"github.com/toolkits/pkg/logger"
|
|
|
|
|
"github.com/toolkits/pkg/runner"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
vers *bool
|
|
|
|
|
help *bool
|
|
|
|
|
conf *string
|
|
|
|
|
|
|
|
|
|
version = "No Version Provided"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
vers = flag.Bool("v", false, "display the version.")
|
|
|
|
|
help = flag.Bool("h", false, "print this help.")
|
|
|
|
|
conf = flag.String("f", "", "specify configuration file.")
|
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
|
|
if *vers {
|
|
|
|
|
fmt.Println("Version:", version)
|
|
|
|
|
os.Exit(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if *help {
|
|
|
|
|
flag.Usage()
|
|
|
|
|
os.Exit(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
runner.Init()
|
|
|
|
|
fmt.Println("runner.cwd:", runner.Cwd)
|
|
|
|
|
fmt.Println("runner.hostname:", runner.Hostname)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
aconf()
|
|
|
|
|
parseConf()
|
|
|
|
|
conf := config.Config
|
|
|
|
|
|
|
|
|
@ -146,12 +179,31 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func parseConf() {
|
|
|
|
|
if err := config.Parse(); err != nil {
|
|
|
|
|
if err := config.Parse(*conf); err != nil {
|
|
|
|
|
fmt.Println("cannot parse configuration file:", err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func aconf() {
|
|
|
|
|
if *conf != "" && file.IsExist(*conf) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*conf = "etc/server.local.yml"
|
|
|
|
|
if file.IsExist(*conf) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*conf = "etc/server.yml"
|
|
|
|
|
if file.IsExist(*conf) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Println("no configuration file for server")
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func checkIdentity() {
|
|
|
|
|
ip, err := identity.GetIP()
|
|
|
|
|
if err != nil {
|
|
|
|
|