mirror of
https://github.com/gwoo/goforever.git
synced 2025-09-27 03:45:51 +08:00
Update usage.
This commit is contained in:
28
README.md
28
README.md
@@ -1,24 +1,30 @@
|
||||
# Goforever [](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 <process> Show a process.
|
||||
start <process> Start a process.
|
||||
stop <process> Stop a process.
|
||||
restart <process> 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
|
||||
|
||||
|
19
goforever.go
19
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
|
||||
Commands
|
||||
list List processes.
|
||||
show <process> Show a process.
|
||||
start <process> Start a process.
|
||||
stop <process> Stop a process.
|
||||
restart <process> Restart a process.
|
||||
end Stop goforever and all 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
|
||||
|
@@ -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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user