summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ponzu/main.go42
-rw-r--r--cmd/ponzu/options.go10
2 files changed, 25 insertions, 27 deletions
diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go
index fcb6035..5b5fa56 100644
--- a/cmd/ponzu/main.go
+++ b/cmd/ponzu/main.go
@@ -125,25 +125,36 @@ func main() {
}
case "run":
- if len(args) < 2 {
- flag.PrintDefaults()
- os.Exit(1)
- }
-
var addTLS string
if tls {
addTLS = "--tls"
} else {
addTLS = "--tls=false"
}
+
+ var services string
+ if len(args) > 1 {
+ services = args[1]
+ } else {
+ services = "admin,api"
+ }
+
serve := exec.Command("./ponzu-server",
fmt.Sprintf("--port=%d", port),
addTLS,
"serve",
- args[1],
+ services,
)
+ serve.Stderr = os.Stderr
+ serve.Stdout = os.Stdout
- err := serve.Run()
+ err := serve.Start()
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+
+ err = serve.Wait()
if err != nil {
fmt.Println(err)
os.Exit(1)
@@ -154,7 +165,6 @@ func main() {
if len(args) > 1 {
services := strings.Split(args[1], ",")
- fmt.Println(args, port, tls)
for i := range services {
if services[i] == "api" {
api.Run()
@@ -166,25 +176,11 @@ func main() {
os.Exit(1)
}
}
- } else {
- if len(args) > 1 {
- if args[1] == "admin" {
- admin.Run()
- }
-
- if args[1] == "api" {
- api.Run()
- }
- } else {
- admin.Run()
- api.Run()
- }
-
}
if tls {
fmt.Println("TLS through Let's Encrypt is not implemented yet.")
- fmt.Println("Please run 'ponzu serve' without the -tls flag for now.")
+ fmt.Println("Please run 'ponzu serve' without the --tls flag for now.")
os.Exit(1)
}
diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go
index 51ecdb3..8f33a78 100644
--- a/cmd/ponzu/options.go
+++ b/cmd/ponzu/options.go
@@ -306,19 +306,16 @@ func buildPonzuServer(args []string) error {
dstFile, err := os.Create(filepath.Join(contentDstPath, srcFileInfo.Name()))
if err != nil {
-
return err
}
srcFile, err := os.Open(filepath.Join(contentSrcPath, srcFileInfo.Name()))
if err != nil {
-
return err
}
_, err = io.Copy(dstFile, srcFile)
if err != nil {
-
return err
}
}
@@ -336,7 +333,12 @@ func buildPonzuServer(args []string) error {
}
// execute go build -o ponzu-cms cmd/ponzu/*.go
- build := exec.Command("go", "build", "-o", "ponzu-server", "cmd/ponzu/*.go")
+ mainPath := filepath.Join(pwd, "cmd", "ponzu", "main.go")
+ optsPath := filepath.Join(pwd, "cmd", "ponzu", "options.go")
+ build := exec.Command("go", "build", "-o", "ponzu-server", mainPath, optsPath)
+ build.Stderr = os.Stderr
+ build.Stdout = os.Stdout
+
err = build.Start()
if err != nil {
return errors.New("Ponzu build step failed. Please try again. " + "\n" + err.Error())