From 4dd18d169915fd6dee412f81854e7310ac78fa4c Mon Sep 17 00:00:00 2001 From: gwoo Date: Sun, 13 Apr 2014 13:44:45 -0700 Subject: [PATCH] Update usage. --- README.md | 28 +++++++++++++++++----------- goforever.go | 21 +++++++-------------- goforever_test.go | 8 +++----- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index c317858..2f74ad2 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,30 @@ # Goforever [![Build Status](https://travis-ci.org/gwoo/goforever.png)](https://travis-ci.org/gwoo/goforever) - Config based process manager. Goforever could be used in place of supervisor, runit, node-forever, etc. Goforever will start an http server on the specified port. - Usage of ./goforever: -conf="goforever.toml": Path to config file. - -d=false: Daemonize goforever. Must be first flag - -password="test": Password for basic auth. - -port=8080: Port for the server. - -username="demo": Username for basic auth. + +## Running +Help. + + ./goforever -h + +Daemonize main process. + + ./goforever start + +Run main process and output to current session. + + ./goforever ## CLI list List processes. - show Show a process. - start Start a process. - stop Stop a process. - restart Restart a process. - + show [process] Show a main proccess or named process. + start [process] Start a main proccess or named process. + stop [process] Stop a main proccess or named process. + restart [process] Restart a main proccess or named process. ## HTTP API diff --git a/goforever.go b/goforever.go index 54a015d..f2ca09d 100644 --- a/goforever.go +++ b/goforever.go @@ -12,7 +12,6 @@ import ( "github.com/gwoo/greq" ) -var d = flag.Bool("d", false, "Daemonize goforever. Must be first flag") var conf = flag.String("conf", "goforever.toml", "Path to config file.") var config *Config var daemon *Process @@ -21,18 +20,18 @@ var Usage = func() { fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) flag.PrintDefaults() usage := ` -Process subcommands - list List processes. - show Show a process. - start Start a process. - stop Stop a process. - restart Restart a process. - end Stop goforever and all processes +Commands + list List processes. + show [name] Show main proccess or named process. + start [name] Start main proccess or named process. + stop [name] Stop main proccess or named process. + restart [name] Restart main proccess or named process. ` fmt.Fprintln(os.Stderr, usage) } func init() { + flag.Usage = Usage flag.Parse() setConfig() daemon = &Process{ @@ -44,15 +43,9 @@ func init() { Errfile: config.Errfile, Respawn: 1, } - flag.Usage = Usage } func main() { - if *d == true { - daemon.Args = append(daemon.Args, os.Args[2:]...) - fmt.Printf(daemon.start(daemon.Name)) - return - } if len(flag.Args()) > 0 { fmt.Printf("%s", Cli()) return diff --git a/goforever_test.go b/goforever_test.go index eb07cfb..d736977 100644 --- a/goforever_test.go +++ b/goforever_test.go @@ -5,7 +5,6 @@ package main import ( //"fmt" - "os" "testing" ) @@ -13,12 +12,11 @@ func Test_main(t *testing.T) { if daemon.Name != "goforever" { t.Error("Daemon name is not goforever") } - os.Args = []string{"./goforever", "-d", "foo"} - dize := true - d = &dize - main() + daemon.Args = []string{"foo"} + daemon.start(daemon.Name) if daemon.Args[0] != "foo" { t.Error("First arg not foo") } + daemon.find() daemon.stop() }