mirror of
https://github.com/gwoo/goforever.git
synced 2025-10-05 23:46:49 +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)
|
# Goforever [](https://travis-ci.org/gwoo/goforever)
|
||||||
|
|
||||||
|
|
||||||
Config based process manager. Goforever could be used in place of supervisor, runit, node-forever, etc.
|
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.
|
Goforever will start an http server on the specified port.
|
||||||
|
|
||||||
|
|
||||||
Usage of ./goforever:
|
Usage of ./goforever:
|
||||||
-conf="goforever.toml": Path to config file.
|
-conf="goforever.toml": Path to config file.
|
||||||
-d=false: Daemonize goforever. Must be first flag
|
|
||||||
-password="test": Password for basic auth.
|
## Running
|
||||||
-port=8080: Port for the server.
|
Help.
|
||||||
-username="demo": Username for basic auth.
|
|
||||||
|
./goforever -h
|
||||||
|
|
||||||
|
Daemonize main process.
|
||||||
|
|
||||||
|
./goforever start
|
||||||
|
|
||||||
|
Run main process and output to current session.
|
||||||
|
|
||||||
|
./goforever
|
||||||
|
|
||||||
## CLI
|
## CLI
|
||||||
list List processes.
|
list List processes.
|
||||||
show <process> Show a process.
|
show [process] Show a main proccess or named process.
|
||||||
start <process> Start a process.
|
start [process] Start a main proccess or named process.
|
||||||
stop <process> Stop a process.
|
stop [process] Stop a main proccess or named process.
|
||||||
restart <process> Restart a process.
|
restart [process] Restart a main proccess or named process.
|
||||||
|
|
||||||
|
|
||||||
## HTTP API
|
## HTTP API
|
||||||
|
|
||||||
|
19
goforever.go
19
goforever.go
@@ -12,7 +12,6 @@ import (
|
|||||||
"github.com/gwoo/greq"
|
"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 conf = flag.String("conf", "goforever.toml", "Path to config file.")
|
||||||
var config *Config
|
var config *Config
|
||||||
var daemon *Process
|
var daemon *Process
|
||||||
@@ -21,18 +20,18 @@ var Usage = func() {
|
|||||||
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
|
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
usage := `
|
usage := `
|
||||||
Process subcommands
|
Commands
|
||||||
list List processes.
|
list List processes.
|
||||||
show <process> Show a process.
|
show [name] Show main proccess or named process.
|
||||||
start <process> Start a process.
|
start [name] Start main proccess or named process.
|
||||||
stop <process> Stop a process.
|
stop [name] Stop main proccess or named process.
|
||||||
restart <process> Restart a process.
|
restart [name] Restart main proccess or named process.
|
||||||
end Stop goforever and all processes
|
|
||||||
`
|
`
|
||||||
fmt.Fprintln(os.Stderr, usage)
|
fmt.Fprintln(os.Stderr, usage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
flag.Usage = Usage
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
setConfig()
|
setConfig()
|
||||||
daemon = &Process{
|
daemon = &Process{
|
||||||
@@ -44,15 +43,9 @@ func init() {
|
|||||||
Errfile: config.Errfile,
|
Errfile: config.Errfile,
|
||||||
Respawn: 1,
|
Respawn: 1,
|
||||||
}
|
}
|
||||||
flag.Usage = Usage
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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 {
|
if len(flag.Args()) > 0 {
|
||||||
fmt.Printf("%s", Cli())
|
fmt.Printf("%s", Cli())
|
||||||
return
|
return
|
||||||
|
@@ -5,7 +5,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
//"fmt"
|
//"fmt"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,12 +12,11 @@ func Test_main(t *testing.T) {
|
|||||||
if daemon.Name != "goforever" {
|
if daemon.Name != "goforever" {
|
||||||
t.Error("Daemon name is not goforever")
|
t.Error("Daemon name is not goforever")
|
||||||
}
|
}
|
||||||
os.Args = []string{"./goforever", "-d", "foo"}
|
daemon.Args = []string{"foo"}
|
||||||
dize := true
|
daemon.start(daemon.Name)
|
||||||
d = &dize
|
|
||||||
main()
|
|
||||||
if daemon.Args[0] != "foo" {
|
if daemon.Args[0] != "foo" {
|
||||||
t.Error("First arg not foo")
|
t.Error("First arg not foo")
|
||||||
}
|
}
|
||||||
|
daemon.find()
|
||||||
daemon.stop()
|
daemon.stop()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user