From 015a23d3eca1938882fb2de274865a75c8524313 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sat, 7 Jan 2017 21:16:27 +0800 Subject: [PATCH] feat: add new flag --pid --- .gitignore | 5 +---- main.go | 14 +++++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index efa4a35..e615e83 100644 --- a/.gitignore +++ b/.gitignore @@ -25,17 +25,14 @@ _testmain.go gin-bin key.pem -config.yml bin/* .DS_Store gorush/log/*.log -build.tar.gz -gorush.tar.gz gorush.db vendor Dockerfile.tmp .cover -*.pid *.db* coverage.txt dist +custom diff --git a/main.go b/main.go index a64a593..0f25056 100644 --- a/main.go +++ b/main.go @@ -36,10 +36,11 @@ Usage: gorush [options] Server Options: -p, --port Use port for clients (default: 8088) - -c, --config Configuration file + -c, --config Configuration file path -m, --message Notification message -t, --token Notification token --proxy Proxy URL (only for GCM) + --pid Process identifier path iOS Options: -i, --key certificate key file path -P, --password certificate key password @@ -93,8 +94,9 @@ func main() { flag.BoolVar(&showVersion, "version", false, "Print version information.") flag.BoolVar(&showVersion, "v", false, "Print version information.") - flag.StringVar(&configFile, "c", "", "Configuration file.") - flag.StringVar(&configFile, "config", "", "Configuration file.") + flag.StringVar(&configFile, "c", "", "Configuration file path.") + flag.StringVar(&configFile, "config", "", "Configuration file path.") + flag.StringVar(&opts.Core.PID.Path, "pid", "", "PID file path.") flag.StringVar(&opts.Ios.KeyPath, "i", "", "iOS certificate key file path") flag.StringVar(&opts.Ios.KeyPath, "key", "", "iOS certificate key file path") flag.StringVar(&opts.Ios.Password, "P", "", "iOS certificate password for gorush") @@ -237,6 +239,12 @@ func main() { gorush.LogError.Fatal(err) } + if opts.Core.PID.Path != "" { + gorush.PushConf.Core.PID.Path = opts.Core.PID.Path + gorush.PushConf.Core.PID.Enabled = true + gorush.PushConf.Core.PID.Override = true + } + if err = createPIDFile(); err != nil { gorush.LogError.Fatal(err) }