2016-03-27 02:58:57 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"github.com/appleboy/gopush/gopush"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
version := flag.Bool("v", false, "gopush version")
|
|
|
|
confPath := flag.String("c", "", "yaml configuration file path for gopush")
|
2016-03-27 04:55:31 +00:00
|
|
|
certificateKeyPath := flag.String("i", "", "iOS certificate key file path for gopush")
|
|
|
|
apiKey := flag.String("k", "", "Android api key configuration for gopush")
|
2016-03-27 02:58:57 +00:00
|
|
|
port := flag.String("p", "", "port number for gopush")
|
|
|
|
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
if *version {
|
|
|
|
gopush.PrintGoPushVersion()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
|
|
|
|
// set default parameters.
|
|
|
|
gopush.PushConf = gopush.BuildDefaultPushConf()
|
|
|
|
|
|
|
|
// load user define config.
|
|
|
|
if *confPath != "" {
|
|
|
|
gopush.PushConf, err = gopush.LoadConfYaml(*confPath)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("Unable to load yaml config file: '%v'", err)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-02 15:51:42 +00:00
|
|
|
if *certificateKeyPath != "" {
|
|
|
|
gopush.PushConf.Ios.PemKeyPath = *certificateKeyPath
|
2016-03-27 02:58:57 +00:00
|
|
|
}
|
|
|
|
|
2016-04-02 15:51:42 +00:00
|
|
|
if *apiKey != "" {
|
|
|
|
gopush.PushConf.Android.ApiKey = *apiKey
|
2016-03-27 04:55:31 +00:00
|
|
|
}
|
|
|
|
|
2016-03-27 02:58:57 +00:00
|
|
|
// overwrite server port
|
|
|
|
if *port != "" {
|
|
|
|
gopush.PushConf.Core.Port = *port
|
|
|
|
}
|
|
|
|
|
2016-04-05 06:50:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
if err = gopush.InitLog(); err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
2016-04-05 05:15:47 +00:00
|
|
|
|
2016-04-02 15:51:42 +00:00
|
|
|
if err = gopush.CheckPushConf(); err != nil {
|
2016-04-05 05:15:47 +00:00
|
|
|
log.Println(err)
|
|
|
|
gopush.LogError.Fatal(err)
|
2016-04-02 15:51:42 +00:00
|
|
|
|
2016-04-02 23:27:10 +00:00
|
|
|
return
|
2016-04-02 15:51:42 +00:00
|
|
|
}
|
|
|
|
|
2016-03-27 05:08:31 +00:00
|
|
|
gopush.InitAPNSClient()
|
2016-03-27 02:58:57 +00:00
|
|
|
gopush.RunHTTPServer()
|
|
|
|
}
|