Add JAR env. Add env debug vode

This commit is contained in:
Jimmy 2021-09-17 22:14:03 +12:00
parent 19700e5b4f
commit 17dd869ff3
1 changed files with 10 additions and 3 deletions

View File

@ -10,15 +10,17 @@ import (
"os/signal" "os/signal"
"strings" "strings"
"syscall" "syscall"
"log"
"github.com/creack/pty" "github.com/creack/pty"
) )
func main() { func main() {
log.Println("Starting Server")
sigs := make(chan os.Signal, 1) sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGTERM) signal.Notify(sigs, syscall.SIGTERM)
var minram, maxram, args, stop string var minram, maxram, args, stop, jar string
for _, e := range os.Environ() { for _, e := range os.Environ() {
pair := strings.SplitN(e, "=", 2) pair := strings.SplitN(e, "=", 2)
switch pair[0] { switch pair[0] {
@ -30,13 +32,18 @@ func main() {
args = pair[1] args = pair[1]
case "STOP": case "STOP":
stop = pair[1] stop = pair[1]
case "JAR":
jar = pair[1]
} }
} }
log.Printf("Ram: Min: %s Max: %s Stop: %s Jar: %s\n\rArgs: %s", minram, maxram, stop, jar, args)
var cmd *exec.Cmd var cmd *exec.Cmd
if args == "" { if args == "" {
cmd = exec.Command("java", minram, maxram, "-jar", "server.jar") cmd = exec.Command("java", minram, maxram, "-jar", jar)
} else { } else {
cmd = exec.Command("java", minram, maxram, args, "-jar", "server.jar") cmd = exec.Command("java", minram, maxram, args, "-jar", jar)
} }
cmd.Dir = "/server" cmd.Dir = "/server"