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"
"strings"
"syscall"
"log"
"github.com/creack/pty"
)
func main() {
log.Println("Starting Server")
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGTERM)
var minram, maxram, args, stop string
var minram, maxram, args, stop, jar string
for _, e := range os.Environ() {
pair := strings.SplitN(e, "=", 2)
switch pair[0] {
@ -30,13 +32,18 @@ func main() {
args = pair[1]
case "STOP":
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
if args == "" {
cmd = exec.Command("java", minram, maxram, "-jar", "server.jar")
cmd = exec.Command("java", minram, maxram, "-jar", jar)
} else {
cmd = exec.Command("java", minram, maxram, args, "-jar", "server.jar")
cmd = exec.Command("java", minram, maxram, args, "-jar", jar)
}
cmd.Dir = "/server"